Documentation
¶
Index ¶
- func Serve(config Config)
- type APIHandle
- type APIService
- func (s *APIService) Delete(endpoint string, handle APIHandle, privilegeIds ...string)
- func (s *APIService) Get(endpoint string, handle APIHandle, privilegeIds ...string)
- func (s *APIService) Head(endpoint string, handle APIHandle, privilegeIds ...string)
- func (s *APIService) Options(endpoint string, cors *CORS)
- func (s *APIService) Patch(endpoint string, handle APIHandle, privilegeIds ...string)
- func (s *APIService) Post(endpoint string, handle APIHandle, privilegeIds ...string)
- func (s *APIService) Put(endpoint string, handle APIHandle, privilegeIds ...string)
- func (s *APIService) Use(middleware MiddlewareHandle)
- type CORS
- type Config
- type Context
- func (ctx *Context) Authenticate(realm string, handle func(user string, password string) (ok bool, err error)) (ok bool, err error)
- func (ctx *Context) End(status int, a ...interface{})
- func (ctx *Context) Error(err error)
- func (ctx *Context) FormBool(key string) (b bool)
- func (ctx *Context) FormInt(key string) (i int, err error)
- func (ctx *Context) FormNumber(key string) (n float64, err error)
- func (ctx *Context) FormString(key string) (value string)
- func (ctx *Context) FormValues(key string) (values []string)
- func (ctx *Context) GetCookie(name string) (cookie *http.Cookie, err error)
- func (ctx *Context) IfModified(modtime time.Time, then func())
- func (ctx *Context) ParseMultipartForm(maxMemoryBytes int64)
- func (ctx *Context) Redirect(url string, code int)
- func (ctx *Context) RemoteIP() (ip string)
- func (ctx *Context) RemoveCookie(cookie *http.Cookie)
- func (ctx *Context) ServeFile(name string)
- func (ctx *Context) Session() (sess session.Session)
- func (ctx *Context) SetCookie(cookie *http.Cookie)
- func (ctx *Context) SetUser(user acl.User)
- func (ctx *Context) User() acl.User
- func (ctx *Context) Write(p []byte) (n int, err error)
- func (ctx *Context) WriteJSON(data interface{}) (n int, err error)
- func (ctx *Context) WriteStatusJSON(status int, data interface{}) (n int, err error)
- func (ctx *Context) WriteString(s string) (n int, err error)
- type MiddlewareHandle
- type Mux
- type ResponseWriter
- type State
- type URL
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIService ¶
type APIService struct {
Prefix string
// contains filtered or unexported fields
}
func NewAPIService ¶
func NewAPIService() *APIService
func NewAPIServiceWithPrefix ¶
func NewAPIServiceWithPrefix(prefix string) *APIService
func (*APIService) Delete ¶
func (s *APIService) Delete(endpoint string, handle APIHandle, privilegeIds ...string)
func (*APIService) Get ¶
func (s *APIService) Get(endpoint string, handle APIHandle, privilegeIds ...string)
func (*APIService) Head ¶
func (s *APIService) Head(endpoint string, handle APIHandle, privilegeIds ...string)
func (*APIService) Options ¶
func (s *APIService) Options(endpoint string, cors *CORS)
func (*APIService) Patch ¶
func (s *APIService) Patch(endpoint string, handle APIHandle, privilegeIds ...string)
func (*APIService) Post ¶
func (s *APIService) Post(endpoint string, handle APIHandle, privilegeIds ...string)
func (*APIService) Put ¶
func (s *APIService) Put(endpoint string, handle APIHandle, privilegeIds ...string)
func (*APIService) Use ¶
func (s *APIService) Use(middleware MiddlewareHandle)
type CORS ¶
type CORS struct {
Origin string
Methods []string
Headers []string
Credentials bool
MaxAge int // seconds
}
func PublicCORS ¶
func PublicCORS() *CORS
type Config ¶
type Config struct {
Port uint16 `json:"port"`
Root string `json:"root"`
ServerName string `json:"serverName"`
CustomHTTPHeaders map[string]string `json:"customHTTPHeaders"`
SessionCookieName string `json:"sessionCookieName"`
HostRedirectRule string `json:"hostRedirectRule"`
ReadTimeout uint32 `json:"readTimeout"`
WriteTimeout uint32 `json:"writeTimeout"`
MaxHeaderBytes uint32 `json:"maxHeaderBytes"`
Debug bool `json:"debug"`
NotFoundHandler http.Handler `json:"-"`
ErrorLogger *log.Logger `json:"-"`
AccessLogger *log.Logger `json:"-"`
}
type Context ¶
type Context struct {
W http.ResponseWriter
R *http.Request
URL *URL
State *State
// contains filtered or unexported fields
}
func (*Context) Authenticate ¶
func (*Context) FormString ¶
func (*Context) FormValues ¶
func (*Context) IfModified ¶ added in v0.2.1
func (*Context) ParseMultipartForm ¶
func (*Context) RemoveCookie ¶
func (*Context) WriteStatusJSON ¶
type MiddlewareHandle ¶
type MiddlewareHandle func(ctx *Context, next func())
type Mux ¶
type Mux struct {
Root string
Debug bool
ServerName string
CustomHTTPHeaders map[string]string
SessionCookieName string
HostRedirectRule string
NotFoundHandler http.Handler
SessionManager session.Manager
AccessLogger *log.Logger
Logger *log.Logger
// contains filtered or unexported fields
}
func (*Mux) RegisterAPIService ¶
func (mux *Mux) RegisterAPIService(apis *APIService)
type ResponseWriter ¶
type ResponseWriter struct {
// contains filtered or unexported fields
}
func (*ResponseWriter) Header ¶
func (w *ResponseWriter) Header() http.Header
func (*ResponseWriter) WriteHeader ¶
func (w *ResponseWriter) WriteHeader(status int)
Directories
¶
| Path | Synopsis |
|---|---|
|
Package httprouter is a trie based high performance HTTP request router.
|
Package httprouter is a trie based high performance HTTP request router. |
Click to show internal directories.
Click to hide internal directories.