Documentation ¶
Index ¶
- Constants
- func MethodNotAllowedHandler() http.Handler
- type Configuration
- type Context
- func (c *Context) Cookies() []*http.Cookie
- func (c *Context) FormParams() (url.Values, error)
- func (c *Context) FormValue(name string) string
- func (c *Context) Get(key string) interface{}
- func (c *Context) GetCookie(key string) (*http.Cookie, error)
- func (c *Context) GetHeader(key string) string
- func (c *Context) JSONBody(v interface{}) error
- func (c *Context) Redirect(status int, url string) error
- func (c *Context) Request() *http.Request
- func (c *Context) Reset(w http.ResponseWriter, r *http.Request)
- func (c *Context) Response() http.ResponseWriter
- func (c *Context) ServeJSON(v interface{}) error
- func (c *Context) Set(key string, value interface{})
- func (c *Context) SetCookie(name string, value string)
- func (c *Context) SetHeader(key, val string)
- func (c *Context) SetRequest(r *http.Request)
- func (c *Context) Validate(val interface{}) error
- func (c *Context) WriteHeader(code int) error
- type Entrypoint
- type FilterFunc
- type HandlerFunc
- type Router
- type TLSConfiguration
Constants ¶
const ( // HTTP methods PUT = "PUT" GET = "GET" POST = "POST" HEAD = "HEAD" PATCH = "PATCH" DELETE = "DELETE" OPTIONS = "OPTIONS" // MIME MIMEApplicationJSON = "application/json" MIMEApplicationJSONCharsetUTF8 = MIMEApplicationJSON + "; " + charsetUTF8 MIMEMultipartForm = "multipart/form-data" // Headers HeaderOrigin = "Origin" HeaderAccept = "Accept" HeaderVary = "Vary" HeaderCookie = "Cookie" HeaderSetCookie = "Set-Cookie" HeaderUpgrade = "Upgrade" HeaderContentType = "Content-Type" HeaderLocation = "Location" HeaderAuthorization = "Authorization" // Access control HeaderAccessControlRequestMethod = "Access-Control-Request-Method" HeaderAccessControlAllowMethods = "Access-Control-Allow-Methods" HeaderAccessControlRequestHeaders = "Access-Control-Request-Headers" HeaderAccessControlAllowOrigin = "Access-Control-Allow-Origin" HeaderAccessControlAllowHeaders = "Access-Control-Allow-Headers" HeaderAccessControlExposeHeaders = "Access-Control-Expose-Headers" HeaderAccessControlAllowCredentials = "Access-Control-Allow-Credentials" HeaderAccessControlMaxAge = "Access-Control-Max-Age" )
Variables ¶
This section is empty.
Functions ¶
func MethodNotAllowedHandler ¶
MethodNotAllowedHandler returns a simple request handler that replies to each request with a “405 method not allowed” reply.
Types ¶
type Context ¶
type Context struct { Validator *validator.Validate LastError error // contains filtered or unexported fields }
Context wraps http.Request and http.ResponseWriter. Returned set to true if response was written to then don't execute other handler.
func NewContext ¶
func NewContext(w http.ResponseWriter, r *http.Request) *Context
NewContext create a new context.
func (*Context) FormParams ¶
FormParams return the parsed form data
func (*Context) Reset ¶
func (c *Context) Reset(w http.ResponseWriter, r *http.Request)
Reset the context.
func (*Context) Response ¶
func (c *Context) Response() http.ResponseWriter
Response return the responseWriter
func (*Context) SetRequest ¶
SetRequest set the r as the new request.
func (*Context) WriteHeader ¶
WriteHeader sends an HTTP response header with status code.
type Entrypoint ¶
type Entrypoint struct {
// contains filtered or unexported fields
}
Entrypoint represents a http server.
func NewEntrypoint ¶
func NewEntrypoint(conf *Configuration, tlsConf *TLSConfiguration) *Entrypoint
NewEntrypoint creates a new Entrypoint.
func (*Entrypoint) AttachMiddleware ¶
func (ep *Entrypoint) AttachMiddleware(handler negroni.Handler)
AttachMiddleware attach a new middleware on entrypoint.
type FilterFunc ¶
FilterFunc defines a filter function which is invoked before the controller handler is executed.
type HandlerFunc ¶
HandlerFunc defines a handler function to handle http request.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router register routes to be matched and dispatched to a handler.
func (*Router) Get ¶
func (rt *Router) Get(pattern string, handler HandlerFunc, filters ...FilterFunc)
Get adds a route path access via GET method.
func (*Router) Post ¶
func (rt *Router) Post(pattern string, handler HandlerFunc, filters ...FilterFunc)
Post adds a route path access via POST method.
func (*Router) SetErrorHandler ¶
SetErrorHandler attach a global error handler on router.
type TLSConfiguration ¶
TLSConfiguration is the configuration for a https server.