Documentation ¶
Index ¶
- Constants
- func DefaultBinder(ctx Context, dest interface{}) error
- func DefaultErrorHandler(code int, err error, ctx Context) error
- type App
- type BindFunc
- type Context
- type ErrorHandler
- type ErrorHandlers
- type HTTPError
- type HandlerFunc
- type Middleware
- type Options
- type Params
- type Response
- type Route
- type Router
- func (r *Router) DELETE(p string, h HandlerFunc)
- func (r *Router) GET(p string, h HandlerFunc)
- func (r *Router) Group(p string) *Router
- func (r *Router) HEAD(p string, h HandlerFunc)
- func (r *Router) OPTIONS(p string, h HandlerFunc)
- func (r *Router) PATCH(p string, h HandlerFunc)
- func (r *Router) POST(p string, h HandlerFunc)
- func (r *Router) PUT(p string, h HandlerFunc)
- func (r *Router) ServeHTTP(res http.ResponseWriter, req *http.Request)
- func (r *Router) SetErrorHandlers(eh map[int]ErrorHandler)
- func (r *Router) Static(p string, fs http.FileSystem)
- func (r *Router) Use(mf ...Middleware)
- type Routes
- type Store
- type ValueParams
- func (p ValueParams) Bool(key string) (bool, error)
- func (p ValueParams) Bools(key string) ([]bool, error)
- func (p ValueParams) Int(key string) (int, error)
- func (p ValueParams) Ints(key string) ([]int, error)
- func (p ValueParams) String(key string) string
- func (p ValueParams) Strings(key string) []string
Constants ¶
const ( HeaderAccept = "Accept" HeaderAcceptEncoding = "Accept-Encoding" HeaderAllow = "Allow" HeaderAuthorization = "Authorization" HeaderContentDisposition = "Content-Disposition" HeaderContentEncoding = "Content-Encoding" HeaderContentLength = "Content-Length" HeaderContentType = "Content-Type" HeaderCookie = "Cookie" HeaderSetCookie = "Set-Cookie" HeaderIfModifiedSince = "If-Modified-Since" HeaderLastModified = "Last-Modified" HeaderLocation = "Location" HeaderUpgrade = "Upgrade" HeaderVary = "Vary" HeaderWWWAuthenticate = "WWW-Authenticate" HeaderXForwardedFor = "X-Forwarded-For" HeaderXForwardedProto = "X-Forwarded-Proto" HeaderXForwardedProtocol = "X-Forwarded-Protocol" HeaderXForwardedSsl = "X-Forwarded-Ssl" HeaderXUrlScheme = "X-Url-Scheme" HeaderXHTTPMethodOverride = "X-HTTP-Method-Override" HeaderXRealIP = "X-Real-IP" HeaderXRequestID = "X-Request-ID" HeaderXRequestedWith = "X-Requested-With" HeaderServer = "Server" HeaderOrigin = "Origin" HeaderAccessControlRequestMethod = "Access-Control-Request-Method" HeaderAccessControlRequestHeaders = "Access-Control-Request-Headers" HeaderAccessControlAllowOrigin = "Access-Control-Allow-Origin" HeaderAccessControlAllowMethods = "Access-Control-Allow-Methods" HeaderAccessControlAllowHeaders = "Access-Control-Allow-Headers" HeaderAccessControlAllowCredentials = "Access-Control-Allow-Credentials" HeaderAccessControlExposeHeaders = "Access-Control-Expose-Headers" HeaderAccessControlMaxAge = "Access-Control-Max-Age" HeaderStrictTransportSecurity = "Strict-Transport-Security" HeaderXContentTypeOptions = "X-Content-Type-Options" HeaderXXSSProtection = "X-XSS-Protection" HeaderXFrameOptions = "X-Frame-Options" HeaderContentSecurityPolicy = "Content-Security-Policy" )
Headers for HTTP
const ( MIMEMultipartForm = "multipart/form-data" MIMEApplicationForm = "application/x-www-form-urlencoded" MIMEApplicationJSON = "application/json" )
Mime types
Variables ¶
This section is empty.
Functions ¶
func DefaultBinder ¶ added in v0.1.4
DefaultBinder checks Content Type from request and tries to decode the body with appropriate decoder
Types ¶
type App ¶
type App struct { *Router // contains filtered or unexported fields }
App holds on to options and the underlying router, the middleware, and more
func (*App) Serve ¶
Serve serves the application at the specified address and listening to OS interrupt and kill signals and will try to shutdown the app gracefully
func (*App) UseAutoTLS ¶ added in v0.1.10
UseAutoTLS will setup autocert.Manager and request cert from https://letsencrypt.org
type Context ¶
type Context interface { JSON(int, interface{}) error HTML(int, string) error String(int, string) error Error(int, error) error NoContent() error Redirect(code int, location string) error Request() *http.Request Response() *Response FormParams() (*ValueParams, error) QueryParams() *ValueParams QueryString() string Bind(interface{}) error Params() Params Set(key string, val interface{}) Get(key string) interface{} }
Context defines interface for otto Context
type ErrorHandler ¶
ErrorHandler defines the interface of a error handler
type ErrorHandlers ¶
type ErrorHandlers struct { DefaultHandler ErrorHandler Handlers map[int]ErrorHandler }
ErrorHandlers holds a list of ErrorHandlers associated to status codes. It also holds a default ErrorHandler that will kick in if there is no other ErrorHandlers
func (ErrorHandlers) Copy ¶ added in v0.1.7
func (e ErrorHandlers) Copy() ErrorHandlers
Copy creates a copy of the ErrorHandlers struct
func (ErrorHandlers) Get ¶
func (e ErrorHandlers) Get(code int) ErrorHandler
Get will return a ErrorHandler that is associated with the provided status code, if none was found the DefaultHandler will be returned
type HandlerFunc ¶
HandlerFunc defines the interface for r Route HandlerFunc
type Middleware ¶
type Middleware func(HandlerFunc) HandlerFunc
Middleware defines the inteface for a otto Middleware
type Options ¶
type Options struct { Addr string StrictSlash bool ReadHeaderTimeout time.Duration WriteTimeout time.Duration IdleTimeout time.Duration MaxHeaderBytes int DisableHTTP2 bool // contains filtered or unexported fields }
Options has all options that can be passed to App
type Params ¶ added in v0.1.5
Params holds url params and provides simple ways to parse the value to different types
type Response ¶
type Response struct { http.ResponseWriter // contains filtered or unexported fields }
Response that holds some information about the response
func (*Response) WriteHeader ¶
WriteHeader writes the code to response writer and stores the status code
type Route ¶
type Route struct { Path string Method string HandlerFunc HandlerFunc // contains filtered or unexported fields }
Route has information about the route
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router handles all middleware, routes and error handlers
func (*Router) DELETE ¶
func (r *Router) DELETE(p string, h HandlerFunc)
DELETE maps an "DELETE" request to the path and handler
func (*Router) GET ¶
func (r *Router) GET(p string, h HandlerFunc)
GET maps an "GET" request to the path and handler
func (*Router) HEAD ¶
func (r *Router) HEAD(p string, h HandlerFunc)
HEAD maps an "HEAD" request to the path and handler
func (*Router) OPTIONS ¶
func (r *Router) OPTIONS(p string, h HandlerFunc)
OPTIONS maps an "OPTIONS" request to the path and handler
func (*Router) PATCH ¶
func (r *Router) PATCH(p string, h HandlerFunc)
PATCH maps an "PATCH" request to the path and handler
func (*Router) POST ¶
func (r *Router) POST(p string, h HandlerFunc)
POST maps an "POST" request to the path and handler
func (*Router) PUT ¶
func (r *Router) PUT(p string, h HandlerFunc)
PUT maps an "PUT" request to the path and handler
func (*Router) SetErrorHandlers ¶
func (r *Router) SetErrorHandlers(eh map[int]ErrorHandler)
SetErrorHandlers associate error handlers with a status code
type ValueParams ¶ added in v0.1.5
type ValueParams struct {
// contains filtered or unexported fields
}
ValueParams holds url.Values and provides simple ways to parse the value to different types
func (ValueParams) Bool ¶ added in v0.1.5
func (p ValueParams) Bool(key string) (bool, error)
Bool gets one value associated with key and returns it as bool
func (ValueParams) Bools ¶ added in v0.1.5
func (p ValueParams) Bools(key string) ([]bool, error)
Bools returns all value associated with key as bool slice
func (ValueParams) Int ¶ added in v0.1.5
func (p ValueParams) Int(key string) (int, error)
Int gets one value associated with key and returns it as int
func (ValueParams) Ints ¶ added in v0.1.5
func (p ValueParams) Ints(key string) ([]int, error)
Ints returns all value associated with key as int slice
func (ValueParams) String ¶ added in v0.1.5
func (p ValueParams) String(key string) string
String gets one value associated with key and returns it as string
func (ValueParams) Strings ¶ added in v0.1.5
func (p ValueParams) Strings(key string) []string
Strings returns all value associated with key as string slice