Documentation
¶
Index ¶
- func Serve(config Config)
- type AutoTLSConfig
- type CORSOptions
- type Config
- type Context
- func (ctx *Context) ACLUser() acl.User
- func (ctx *Context) AddHeader(key string, value string)
- func (ctx *Context) BasicUser() acl.BasicUser
- func (ctx *Context) End(status int, a ...string)
- func (ctx *Context) Error(err error)
- func (ctx *Context) File(filename string)
- func (ctx *Context) FormFile(key string) (multipart.File, *multipart.FileHeader, error)
- func (ctx *Context) FormString(key string, defaultValue ...string) string
- func (ctx *Context) FormValue(key string, defaultValue ...string) FormValue
- func (ctx *Context) FormValues(key string) (a []string)
- func (ctx *Context) GetCookie(name string) (cookie *http.Cookie, err error)
- func (ctx *Context) GetHeader(key string) string
- func (ctx *Context) HTML(html string)
- func (ctx *Context) IfModified(modtime time.Time, then func())
- func (ctx *Context) IfNotMatch(etag string, then func())
- func (ctx *Context) JSON(v interface{})
- func (ctx *Context) JSONError(err error)
- func (ctx *Context) MustACLUser() acl.User
- func (ctx *Context) MustBasicUser() acl.BasicUser
- func (ctx *Context) Next()
- func (ctx *Context) Ok(text string)
- func (ctx *Context) ParseMultipartForm(maxMemoryBytes int64)
- func (ctx *Context) Redirect(status int, url string)
- func (ctx *Context) RemoteIP() string
- func (ctx *Context) RemoveCookie(cookie *http.Cookie)
- func (ctx *Context) RemoveCookieByName(name string, path string, domain string)
- func (ctx *Context) Render(template Template, data interface{})
- func (ctx *Context) RenderHTML(html string, data interface{})
- func (ctx *Context) Session() *ContextSession
- func (ctx *Context) SetCookie(cookie *http.Cookie)
- func (ctx *Context) SetHeader(key string, value string)
- func (ctx *Context) Zip(path string)
- type ContextSession
- type CookieSIDtore
- type FormValue
- type HTTPSConfig
- type Handle
- func ACLAuth(getUserFunc func(ctx *Context) (acl.User, error)) Handle
- func BasicAuth(check func(name string, password string) (ok bool, err error)) Handle
- func BasicAuthWithRealm(realm string, check func(name string, password string) (ok bool, err error)) Handle
- func CORS(opts CORSOptions) Handle
- func HTTPS() Handle
- func Header(key string, value string) Handle
- func Privileges(privileges ...string) Handle
- func SessionManager(sidStore SIDStore, pool session.Pool) Handle
- func Static(root string, fallbackPaths ...string) Handle
- type InvalidError
- type Logger
- type REST
- func (rest *REST) Delete(path string, handles ...Handle)
- func (rest *REST) Get(path string, handles ...Handle)
- func (rest *REST) Handle(method string, path string, handles ...Handle)
- func (rest *REST) Head(path string, handles ...Handle)
- func (rest *REST) New(prefix ...string) *REST
- func (rest *REST) NotFound(handles ...Handle)
- func (rest *REST) Options(path string, handles ...Handle)
- func (rest *REST) Patch(path string, handles ...Handle)
- func (rest *REST) Post(path string, handles ...Handle)
- func (rest *REST) Put(path string, handles ...Handle)
- func (rest *REST) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (rest *REST) Use(middlewares ...Handle)
- type SIDStore
- type ServerError
- type State
- type Template
- type URL
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AutoTLSConfig ¶ added in v0.4.0
type CORSOptions ¶ added in v0.5.0
type Context ¶
type Context struct {
W http.ResponseWriter
R *http.Request
URL *URL
State *State
// contains filtered or unexported fields
}
func (*Context) FormString ¶
func (*Context) FormValues ¶
func (*Context) IfModified ¶ added in v0.2.1
func (*Context) IfNotMatch ¶ added in v0.5.0
func (*Context) MustACLUser ¶ added in v0.6.0
func (*Context) MustBasicUser ¶ added in v0.8.0
func (*Context) ParseMultipartForm ¶
func (*Context) RemoveCookie ¶
func (*Context) RemoveCookieByName ¶ added in v0.8.0
func (*Context) RenderHTML ¶ added in v0.5.8
func (*Context) Session ¶
func (ctx *Context) Session() *ContextSession
type ContextSession ¶ added in v0.6.1
type ContextSession struct {
// contains filtered or unexported fields
}
func (*ContextSession) Delete ¶ added in v0.6.1
func (s *ContextSession) Delete(key string)
func (*ContextSession) Flush ¶ added in v0.6.1
func (s *ContextSession) Flush()
func (*ContextSession) Get ¶ added in v0.6.1
func (s *ContextSession) Get(key string) interface{}
func (*ContextSession) Has ¶ added in v0.6.1
func (s *ContextSession) Has(key string) bool
func (*ContextSession) SID ¶ added in v0.6.1
func (s *ContextSession) SID() string
func (*ContextSession) Set ¶ added in v0.6.1
func (s *ContextSession) Set(key string, value interface{})
type CookieSIDtore ¶ added in v0.6.2
type CookieSIDtore struct {
CookieName string
}
func (*CookieSIDtore) Get ¶ added in v0.6.2
func (s *CookieSIDtore) Get(ctx *Context) string
func (*CookieSIDtore) Put ¶ added in v0.8.0
func (s *CookieSIDtore) Put(ctx *Context, sid string)
type HTTPSConfig ¶ added in v0.3.0
type HTTPSConfig struct {
Port uint16 `json:"port"`
CertFile string `json:"certFile"`
KeyFile string `json:"keyFile"`
AutoTLS AutoTLSConfig `json:"autotls"`
}
type Handle ¶ added in v0.8.0
type Handle func(ctx *Context)
Handle defines the handle of route or middleware of REST
func BasicAuthWithRealm ¶ added in v0.8.0
func BasicAuthWithRealm(realm string, check func(name string, password string) (ok bool, err error)) Handle
BasicAuthWithRealm returns a Basic HTTP Authorization middleware with realm.
func CORS ¶
func CORS(opts CORSOptions) Handle
func Privileges ¶ added in v0.5.0
func SessionManager ¶ added in v0.5.0
SessionManager returns a SessionManager middleware.
type InvalidError ¶ added in v0.7.4
func Invalid ¶ added in v0.7.4
func Invalid(code int, message string) *InvalidError
func (*InvalidError) Error ¶ added in v0.7.4
func (err *InvalidError) Error() string
type Logger ¶ added in v0.5.0
type Logger interface {
Println(v ...interface{})
Printf(format string, v ...interface{})
}
type REST ¶ added in v0.4.0
type REST struct {
// Logger to log accesses
AccessLogger Logger
// Logger to log errors
Logger Logger
// If enabled, errors will be sent to the client.
// should be disable in production
SendError bool
// contains filtered or unexported fields
}
REST is a http.Handler which contains the router, middlewares and configuration settings
func (*REST) Delete ¶ added in v0.4.0
Delete is a shortcut for router.Handle("DELETE", path, handles)
func (*REST) Handle ¶ added in v0.4.0
Handle registers a new request handle with the given method and path.
func (*REST) Options ¶ added in v0.4.0
Options is a shortcut for router.Handle("OPTIONS", path, handles)
type ServerError ¶ added in v0.7.4
type ServerError string
func (ServerError) Error ¶ added in v0.7.4
func (err ServerError) Error() string
Source Files
¶
Click to show internal directories.
Click to hide internal directories.