Documentation ¶
Overview ¶
Package hador is a high preformance and easy to use web framework in Go.
example:
package main import "github.com/Xuyuanp/hador" func main() { h := hador.New() h.AddFilters( h.NewLogFilter(h.Logger), ) h.Group("/v1", func(root hador.Router) { root.Get("/hello", func(ctx hador.Context) { ctx.Response.Write([]byte("hello")) }, f2) root.Get(`/hello/{name:\w+}`, func(ctx hador.Context) { name := ctx.Params().GetStringMust("name", "") ctx.Response.Write([]byte("hello " + name)) }, f3, f4) }, f1) h.Get("/hello", func(ctx hador.Context) { ctx.Response.Write([]byte("hello")) }, f5) h.Run(":<your_port>") }
GET /hello
LogFilter -> f5 -> handler -> f5 -> LogFilter
GET /v1/hello
LogFilter -> f1 -> f2 -> handler -> f2 -> f1 -> LogFilter
GET /v1/hello/alice
LogFilter -> f1 -> f3 -> f4 -> handler -> f4 -> f3 -> f1 -> LogFilter
Index ¶
- Constants
- Variables
- type BaseController
- func (c *BaseController) Connect(ctx *Context)
- func (c *BaseController) Delete(ctx *Context)
- func (c *BaseController) DocConnect(leaf *Leaf)
- func (c *BaseController) DocDelete(leaf *Leaf)
- func (c *BaseController) DocGet(leaf *Leaf)
- func (c *BaseController) DocHead(leaf *Leaf)
- func (c *BaseController) DocOptions(leaf *Leaf)
- func (c *BaseController) DocPatch(leaf *Leaf)
- func (c *BaseController) DocPost(leaf *Leaf)
- func (c *BaseController) DocPut(leaf *Leaf)
- func (c *BaseController) DocTrace(leaf *Leaf)
- func (c *BaseController) Get(ctx *Context)
- func (c *BaseController) Head(ctx *Context)
- func (c *BaseController) Options(ctx *Context)
- func (c *BaseController) Patch(ctx *Context)
- func (c *BaseController) Post(ctx *Context)
- func (c *BaseController) Prepare(ctx *Context) bool
- func (c *BaseController) Put(ctx *Context)
- func (c *BaseController) Trace(ctx *Context)
- type Beforer
- type Context
- func (ctx *Context) Delete(key string) interface{}
- func (ctx *Context) Get(key string) interface{}
- func (ctx *Context) GetOK(key string) (value interface{}, ok bool)
- func (ctx *Context) OnError(status int, args ...interface{})
- func (ctx *Context) Params() Params
- func (ctx *Context) Redirect(url string, status int)
- func (ctx *Context) RenderJSON(v interface{}, status ...int) error
- func (ctx *Context) RenderJSONP(v interface{}, callback string, status int) error
- func (ctx *Context) RenderPrettyJSON(v interface{}, status ...int) error
- func (ctx *Context) RenderPrettyXML(v interface{}, status ...int) error
- func (ctx *Context) RenderXML(v interface{}, status ...int) error
- func (ctx *Context) ResolveJSON(v interface{}) error
- func (ctx *Context) ResolveXML(v interface{}) error
- func (ctx *Context) Set(key string, value interface{})
- func (ctx *Context) SetErrorHandler(status int, handler func(...interface{}))
- func (ctx *Context) SetHeader(key, value string)
- func (ctx *Context) Write(p []byte) (n int, err error)
- func (ctx *Context) WriteHeader(status int)
- func (ctx *Context) WriteStatus(p []byte, status ...int) (n int, err error)
- func (ctx *Context) WriteString(s string, status ...int) (n int, err error)
- type ControllerFilter
- type ControllerInterface
- type Filter
- type FilterChain
- func (fc *FilterChain) AddFilters(filters ...Filter)
- func (fc *FilterChain) Before(filter Filter) Beforer
- func (fc *FilterChain) BeforeFunc(f func(*Context, Handler)) Beforer
- func (fc *FilterChain) InsertBack(filters ...Filter)
- func (fc *FilterChain) InsertFront(filters ...Filter)
- func (fc *FilterChain) Serve(ctx *Context)
- type FilterFunc
- type Grouper
- type HTTPError
- type Hador
- func (h *Hador) AddFilters(filters ...Filter) *Hador
- func (h *Hador) Run(addr string) error
- func (h *Hador) RunExitOnError(addr string)
- func (h *Hador) RunTLS(addr, sertFile, keyFile string) error
- func (h *Hador) RunTLSExitOnError(addr, sertFile, keyFile string)
- func (h *Hador) Serve(ctx *Context)
- func (h *Hador) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (h *Hador) Swagger(config SwaggerConfig) *Leaf
- func (h *Hador) SwaggerDocument() *swagger.Document
- func (h *Hador) SwaggerHandler() Handler
- type Handler
- type HandlerFunc
- type HandlerSetter
- type Leaf
- type Logger
- type Method
- type MethodSetter
- func (ms MethodSetter) Connect() PatternSetter
- func (ms MethodSetter) Delete() PatternSetter
- func (ms MethodSetter) Get() PatternSetter
- func (ms MethodSetter) Group(root string) Grouper
- func (ms MethodSetter) Head() PatternSetter
- func (ms MethodSetter) Method(method Method) PatternSetter
- func (ms MethodSetter) Options() PatternSetter
- func (ms MethodSetter) Patch() PatternSetter
- func (ms MethodSetter) Post() PatternSetter
- func (ms MethodSetter) Put() PatternSetter
- func (ms MethodSetter) Trace() PatternSetter
- type Middleware
- type Param
- type Params
- func (params Params) GetBool(key string) (bool, error)
- func (params Params) GetBoolMust(key string, def bool) bool
- func (params Params) GetFloat32(key string) (float32, error)
- func (params Params) GetFloat32Must(key string, def float32) float32
- func (params Params) GetFloat64(key string) (float64, error)
- func (params Params) GetFloat64Must(key string, def float64) float64
- func (params Params) GetInt(key string) (int, error)
- func (params Params) GetInt16(key string) (int16, error)
- func (params Params) GetInt16Must(key string, def int16) int16
- func (params Params) GetInt32(key string) (int32, error)
- func (params Params) GetInt32Must(key string, def int32) int32
- func (params Params) GetInt64(key string) (int64, error)
- func (params Params) GetInt64Must(key string, def int64) int64
- func (params Params) GetInt8(key string) (int8, error)
- func (params Params) GetInt8Must(key string, def int8) int8
- func (params Params) GetIntMust(key string, def int) int
- func (params Params) GetString(key string) (string, error)
- func (params Params) GetStringMust(key string, def string) string
- func (params Params) GetUint(key string) (uint, error)
- func (params Params) GetUint16(key string) (uint16, error)
- func (params Params) GetUint16Must(key string, def uint16) uint16
- func (params Params) GetUint32(key string) (uint32, error)
- func (params Params) GetUint32Must(key string, def uint32) uint32
- func (params Params) GetUint64(key string) (uint64, error)
- func (params Params) GetUint64Must(key string, def uint64) uint64
- func (params Params) GetUint8(key string) (uint8, error)
- func (params Params) GetUint8Must(key string, def uint8) uint8
- func (params Params) GetUintMust(key string, def uint) uint
- type PatternSetter
- type ResponseWriter
- type Router
- type RouterFunc
- func (r RouterFunc) AddController(pattern string, controller ControllerInterface, filters ...Filter)
- func (r RouterFunc) AddRoute(method Method, pattern string, handler interface{}, filters ...Filter) *Leaf
- func (r RouterFunc) Any(pattern string, handler interface{}, filters ...Filter) *Leaf
- func (r RouterFunc) Connect(pattern string, handler interface{}, filters ...Filter) *Leaf
- func (r RouterFunc) Delete(pattern string, handler interface{}, filters ...Filter) *Leaf
- func (r RouterFunc) Get(pattern string, handler interface{}, filters ...Filter) *Leaf
- func (r RouterFunc) Group(pattern string, fn func(Router), filters ...Filter)
- func (r RouterFunc) Head(pattern string, handler interface{}, filters ...Filter) *Leaf
- func (r RouterFunc) Options(pattern string, handler interface{}, filters ...Filter) *Leaf
- func (r RouterFunc) Patch(pattern string, handler interface{}, filters ...Filter) *Leaf
- func (r RouterFunc) Post(pattern string, handler interface{}, filters ...Filter) *Leaf
- func (r RouterFunc) Put(pattern string, handler interface{}, filters ...Filter) *Leaf
- func (r RouterFunc) Route() MethodSetter
- func (r RouterFunc) Trace(pattern string, handler interface{}, filters ...Filter) *Leaf
- type Static
- type SwaggerConfig
Constants ¶
const ( OPTIONS Method = "OPTIONS" GET = "GET" HEAD = "HEAD" POST = "POST" PUT = "PUT" DELETE = "DELETE" TRACE = "TRACE" CONNECT = "CONNECT" PATCH = "PATCH" )
available methods.
const Version = "0.1.0"
Version is the current version number. Version format is '[major].[minor].[patch]'
Major: a large or potentially backward-incompatible API. Minor: a new minor feature or a set of smaller features. Patch: small bugfixed.
Variables ¶
Methods is a list of all valid methods.
Functions ¶
This section is empty.
Types ¶
type BaseController ¶
type BaseController struct { }
BaseController provides an empty controller, returns Not Implemented status in any method.
func (*BaseController) Connect ¶
func (c *BaseController) Connect(ctx *Context)
Connect implements ControllerInterface.
func (*BaseController) Delete ¶
func (c *BaseController) Delete(ctx *Context)
Delete implements ControllerInterface.
func (*BaseController) DocConnect ¶
func (c *BaseController) DocConnect(leaf *Leaf)
DocConnect implements ControllerInterface.
func (*BaseController) DocDelete ¶
func (c *BaseController) DocDelete(leaf *Leaf)
DocDelete implements ControllerInterface.
func (*BaseController) DocGet ¶
func (c *BaseController) DocGet(leaf *Leaf)
DocGet implements ControllerInterface.
func (*BaseController) DocHead ¶
func (c *BaseController) DocHead(leaf *Leaf)
DocHead implements ControllerInterface.
func (*BaseController) DocOptions ¶
func (c *BaseController) DocOptions(leaf *Leaf)
DocOptions implements ControllerInterface.
func (*BaseController) DocPatch ¶
func (c *BaseController) DocPatch(leaf *Leaf)
DocPatch implements ControllerInterface.
func (*BaseController) DocPost ¶
func (c *BaseController) DocPost(leaf *Leaf)
DocPost implements ControllerInterface.
func (*BaseController) DocPut ¶
func (c *BaseController) DocPut(leaf *Leaf)
DocPut implements ControllerInterface.
func (*BaseController) DocTrace ¶
func (c *BaseController) DocTrace(leaf *Leaf)
DocTrace implements ControllerInterface.
func (*BaseController) Get ¶
func (c *BaseController) Get(ctx *Context)
Get implements ControllerInterface.
func (*BaseController) Head ¶
func (c *BaseController) Head(ctx *Context)
Head implements ControllerInterface.
func (*BaseController) Options ¶
func (c *BaseController) Options(ctx *Context)
Options implements ControllerInterface.
func (*BaseController) Patch ¶
func (c *BaseController) Patch(ctx *Context)
Patch implements ControllerInterface.
func (*BaseController) Post ¶
func (c *BaseController) Post(ctx *Context)
Post implements ControllerInterface.
func (*BaseController) Prepare ¶
func (c *BaseController) Prepare(ctx *Context) bool
Prepare runs before other methods, and ends this request if returns false.
func (*BaseController) Put ¶
func (c *BaseController) Put(ctx *Context)
Put implements ControllerInterface.
func (*BaseController) Trace ¶
func (c *BaseController) Trace(ctx *Context)
Trace implements ControllerInterface.
type Context ¶
type Context struct { Request *http.Request Response ResponseWriter Logger Logger Err4XXHandler func(int, ...interface{}) Err5XXHandler func(int, ...interface{}) // contains filtered or unexported fields }
Context struct
func (*Context) OnError ¶
OnError handles http error by calling handler registered in SetErrorHandler methods. If no handler registered with this status and noting written yet, http.Error would be used.
func (*Context) RenderJSON ¶
RenderJSON renders v in JSON format and sets status if provided.
func (*Context) RenderJSONP ¶
RenderJSONP method.
func (*Context) RenderPrettyJSON ¶
RenderPrettyJSON renders v in pretty JSON format and sets status if provided.
func (*Context) RenderPrettyXML ¶
RenderPrettyXML renders v in pretty XML format and sets status if provided.
func (*Context) ResolveJSON ¶
ResolveJSON resolve the request body into JSON format.
func (*Context) ResolveXML ¶
ResolveXML resolve the request body into XML format.
func (*Context) SetErrorHandler ¶
SetErrorHandler sets custom handler for each http error
func (*Context) WriteHeader ¶
WriteHeader writes header by calling ctx.Response.WriteHeader method
func (*Context) WriteStatus ¶
WriteStatus writes data into response by calling ctx.Response.Write method, and sets status as provided, if multi status provided, the first one will be used, if no status provided, does noting.
type ControllerFilter ¶
type ControllerFilter struct {
// contains filtered or unexported fields
}
ControllerFilter filters controller by using controller.Prepare methods.
func (*ControllerFilter) Filter ¶
func (cf *ControllerFilter) Filter(ctx *Context, next Handler)
Filter implements Filter interface.
type ControllerInterface ¶
type ControllerInterface interface { // If Prepare method returns false, this request will be ended. Prepare(ctx *Context) bool Options(ctx *Context) Get(ctx *Context) Head(ctx *Context) Post(ctx *Context) Put(ctx *Context) Delete(ctx *Context) Trace(ctx *Context) Connect(ctx *Context) Patch(ctx *Context) DocOptions(leaf *Leaf) DocGet(leaf *Leaf) DocHead(leaf *Leaf) DocPost(leaf *Leaf) DocPut(leaf *Leaf) DocDelete(leaf *Leaf) DocTrace(leaf *Leaf) DocConnect(leaf *Leaf) DocPatch(leaf *Leaf) }
ControllerInterface is definition of controller API.
type Filter ¶
Filter interface
func Combine2Filters ¶
Combine2Filters combines 2 Filters into a single Filter.
func CombineFilters ¶
CombineFilters combines multi Filters into a single Filter.
type FilterChain ¶
type FilterChain filterHandler
FilterChain struct combines multi Filters and Handler into a single Handler.
func NewFilterChain ¶
func NewFilterChain(handler Handler, filters ...Filter) *FilterChain
NewFilterChain creates new FilterChain instance
func (*FilterChain) AddFilters ¶
func (fc *FilterChain) AddFilters(filters ...Filter)
AddFilters adds all filters to chain
func (*FilterChain) Before ¶
func (fc *FilterChain) Before(filter Filter) Beforer
Before implements Beforer interface
func (*FilterChain) BeforeFunc ¶
func (fc *FilterChain) BeforeFunc(f func(*Context, Handler)) Beforer
BeforeFunc implements Beforer interface
func (*FilterChain) InsertBack ¶
func (fc *FilterChain) InsertBack(filters ...Filter)
InsertBack inserts filters after self
func (*FilterChain) InsertFront ¶
func (fc *FilterChain) InsertFront(filters ...Filter)
InsertFront insert filters before self
func (*FilterChain) Serve ¶
func (fc *FilterChain) Serve(ctx *Context)
Serve implements Handler interface
type FilterFunc ¶
FilterFunc as function
func NewLogFilter ¶
func NewLogFilter(logger Logger) FilterFunc
NewLogFilter new a Filter to log each request details
func NewRecoveryFilter ¶
func NewRecoveryFilter(logger Logger) FilterFunc
NewRecoveryFilter return a Filter to recover all unrecovered panic
func (FilterFunc) Filter ¶
func (ff FilterFunc) Filter(ctx *Context, next Handler)
Filter implements Filter interface
type Grouper ¶
Grouper type is a group routing tool.
type Hador ¶
type Hador struct { Router *FilterChain Logger Logger // contains filtered or unexported fields }
Hador struct
func Default ¶
func Default() *Hador
Default creates Hador instance with default filters(LogFilter, RecoveryFilter)
func (*Hador) AddFilters ¶
AddFilters reuses FilterChain's AddFilters method and returns self
func (*Hador) RunExitOnError ¶
RunExitOnError starts serving HTTP request and exit app if any error occurs.
func (*Hador) RunTLSExitOnError ¶
RunTLSExitOnError starts serving HTTPS request and exit app if any error occurs.
func (*Hador) Swagger ¶
func (h *Hador) Swagger(config SwaggerConfig) *Leaf
Swagger setups swagger config, returns json API path Leaf
func (*Hador) SwaggerDocument ¶
SwaggerDocument returns swagger.Document of this Hador.
func (*Hador) SwaggerHandler ¶
SwaggerHandler returns swagger json api handler
type HandlerFunc ¶
type HandlerFunc func(ctx *Context)
HandlerFunc is Handle as function
func WrapFunc ¶
func WrapFunc(hf func(http.ResponseWriter, *http.Request)) HandlerFunc
WrapFunc wraps http.HandlerFunc to HandlerFunc
func (HandlerFunc) Serve ¶
func (hf HandlerFunc) Serve(ctx *Context)
Serve implements Handler interface by calling HandlerFunc function
type HandlerSetter ¶
HandlerSetter easy way to set Handler for a route.
func (HandlerSetter) Filters ¶
func (hs HandlerSetter) Filters(filters ...Filter) HandlerSetter
Filters creates a new HandlerSetter to append filters.
func (HandlerSetter) Handler ¶
func (hs HandlerSetter) Handler(handler interface{}, filters ...Filter) *Leaf
Handler calls HandlerSetter function.
type Leaf ¶
type Leaf struct { *FilterChain DocIgnored bool // contains filtered or unexported fields }
Leaf struct
func (*Leaf) AddFilters ¶
AddFilters add filters into FilterChain
func (*Leaf) SwaggerOperation ¶
SwaggerOperation returns swagger Operation of this route.
type Logger ¶
type Logger interface { Debug(string, ...interface{}) Info(string, ...interface{}) Warning(string, ...interface{}) Error(string, ...interface{}) Critical(string, ...interface{}) }
Logger interface
type MethodSetter ¶
type MethodSetter func(method Method) PatternSetter
MethodSetter easy way to set Method for a route.
func (MethodSetter) Connect ¶
func (ms MethodSetter) Connect() PatternSetter
Connect short for Method(CONNECT)
func (MethodSetter) Delete ¶
func (ms MethodSetter) Delete() PatternSetter
Delete short for Method(DELETE)
func (MethodSetter) Group ¶
func (ms MethodSetter) Group(root string) Grouper
Group creates a new Grouper with root.
func (MethodSetter) Method ¶
func (ms MethodSetter) Method(method Method) PatternSetter
Method calls MethodSetter function.
func (MethodSetter) Options ¶
func (ms MethodSetter) Options() PatternSetter
Options short for Method(OPTIONS)
func (MethodSetter) Patch ¶
func (ms MethodSetter) Patch() PatternSetter
Patch short for Method(PATCH)
func (MethodSetter) Trace ¶
func (ms MethodSetter) Trace() PatternSetter
Trace short for Method(TRACE)
type Middleware ¶
Middleware is another type of Filter.
func (Middleware) Filter ¶
func (mw Middleware) Filter(ctx *Context, next Handler)
Filter implements Filter interface.
type Params ¶
type Params []Param
Params is a wrapper of map[string]string to handle the params in regexp pattern. If the handler's URL pattern is "/api/(?P<name>\w+)/{age:\d+}" and the request URL is "/api/jack/12", the Params will be { "name": "jack", "age": "12" }. Using `hodor.GetParams(req)` to get the Params. type Params map[string]string
func (Params) GetBoolMust ¶
GetBoolMust gets params with key in boolean format
func (Params) GetFloat32 ¶
GetFloat32 gets params with key in float32 format
func (Params) GetFloat32Must ¶
GetFloat32Must gets params with key in float32 format
func (Params) GetFloat64 ¶
GetFloat64 gets params with key in float64 format
func (Params) GetFloat64Must ¶
GetFloat64Must gets params with key in float64 format
func (Params) GetInt ¶
GetInt method does the same work as GetString, but converts the string into integer. If the param is not a valid integer, an err will be returned.
func (Params) GetInt16Must ¶
GetInt16Must gets params with key in int16 format
func (Params) GetInt32Must ¶
GetInt32Must gets params with key in int32 format
func (Params) GetInt64Must ¶
GetInt64Must gets params with key in int64 format
func (Params) GetInt8Must ¶
GetInt8Must gets params with key in int8 format
func (Params) GetIntMust ¶
GetIntMust method does the same work as GetStringMust, but converts the string into integer. If the param is not a valid integer, the default value will be returned.
func (Params) GetStringMust ¶
GetStringMust method returns the param named `key` as string type. If no param with the provided name, the default value will be returned.
func (Params) GetUint16Must ¶
GetUint16Must gets params with key in uint16 format
func (Params) GetUint32Must ¶
GetUint32Must gets params with key in uint32 format
func (Params) GetUint64Must ¶
GetUint64Must gets params with key in uint64 format
func (Params) GetUint8Must ¶
GetUint8Must gets params with key in uint8 format
type PatternSetter ¶
type PatternSetter func(pattern string) HandlerSetter
PatternSetter easy way to set Path for a route.
func (PatternSetter) Pattern ¶
func (ps PatternSetter) Pattern(pattern string) HandlerSetter
Pattern calls Pattern function.
type ResponseWriter ¶
type ResponseWriter interface { http.ResponseWriter http.Flusher // Status returns the status code of the response or 0 if the response has not been written. Status() int WriteString(string) (int, error) // Written returns whether or not the ResponseWriter has been written. Written() bool // Size returns the size of the response body. Size() int // Before allows for a function to be called before the ResponseWriter has been written to. This is // useful for setting headers or any other operations that must happen before a response has been written. Before(func(ResponseWriter)) }
ResponseWriter is a wrapper around http.ResponseWriter that provides extra information about the response. It is recommended that middleware handlers use this construct to wrap a responsewriter if the functionality calls for it.
func NewResponseWriter ¶
func NewResponseWriter(rw http.ResponseWriter) ResponseWriter
NewResponseWriter creates a ResponseWriter that wraps an http.ResponseWriter
type Router ¶
type Router interface { Route() MethodSetter Options(pattern string, h interface{}, filters ...Filter) *Leaf Get(pattern string, h interface{}, filters ...Filter) *Leaf Head(pattern string, h interface{}, filters ...Filter) *Leaf Post(pattern string, h interface{}, filters ...Filter) *Leaf Put(pattern string, h interface{}, filters ...Filter) *Leaf Delete(pattern string, h interface{}, filters ...Filter) *Leaf Trace(pattern string, h interface{}, filters ...Filter) *Leaf Connect(pattern string, h interface{}, filters ...Filter) *Leaf Patch(pattern string, h interface{}, filters ...Filter) *Leaf // Any routes doesn't support swagger API, always returns nil. Any(pattern string, h interface{}, filters ...Filter) *Leaf // Be carefull! All requests match this pattern would be processed by the provided // controller instance, no new ControllerInterface implemented instance would be // created. If you want to share data in your controller, please make sure it is // goroutine-safe. AddController(pattern string, controller ControllerInterface, filters ...Filter) AddRoute(method Method, pattern string, h interface{}, filters ...Filter) *Leaf Group(pattern string, fn func(Router), filters ...Filter) }
Router interface
type RouterFunc ¶
RouterFunc is a function type implemented Router interface.
func (RouterFunc) AddController ¶
func (r RouterFunc) AddController(pattern string, controller ControllerInterface, filters ...Filter)
AddController adds routes of all methods by calling controller's matched method.
func (RouterFunc) AddRoute ¶
func (r RouterFunc) AddRoute(method Method, pattern string, handler interface{}, filters ...Filter) *Leaf
AddRoute calls RouterFunc function. It is the most important method of RouterFunc. All other methods call this method finally.
func (RouterFunc) Any ¶
func (r RouterFunc) Any(pattern string, handler interface{}, filters ...Filter) *Leaf
Any adds a new route binded with all method.
func (RouterFunc) Connect ¶
func (r RouterFunc) Connect(pattern string, handler interface{}, filters ...Filter) *Leaf
Connect adds a new route binded with CONNECT method.
func (RouterFunc) Delete ¶
func (r RouterFunc) Delete(pattern string, handler interface{}, filters ...Filter) *Leaf
Delete adds a new route binded with DELETE method.
func (RouterFunc) Get ¶
func (r RouterFunc) Get(pattern string, handler interface{}, filters ...Filter) *Leaf
Get adds a new route binded with GET method.
func (RouterFunc) Group ¶
func (r RouterFunc) Group(pattern string, fn func(Router), filters ...Filter)
Group adds multi routes one time.
func (RouterFunc) Head ¶
func (r RouterFunc) Head(pattern string, handler interface{}, filters ...Filter) *Leaf
Head adds a new route binded with HEAD method.
func (RouterFunc) Options ¶
func (r RouterFunc) Options(pattern string, handler interface{}, filters ...Filter) *Leaf
Options adds a new route binded with OPTIONS method.
func (RouterFunc) Patch ¶
func (r RouterFunc) Patch(pattern string, handler interface{}, filters ...Filter) *Leaf
Patch adds a new route binded with Patch method.
func (RouterFunc) Post ¶
func (r RouterFunc) Post(pattern string, handler interface{}, filters ...Filter) *Leaf
Post adds a new route binded with POST method.
func (RouterFunc) Put ¶
func (r RouterFunc) Put(pattern string, handler interface{}, filters ...Filter) *Leaf
Put adds a new route binded with PUT method.
func (RouterFunc) Route ¶
func (r RouterFunc) Route() MethodSetter
Route returns a setter-chain to add a new route step-by-step.
type Static ¶
type Static struct { Prefix string IndexFile string Dir http.FileSystem }
Static struct
type SwaggerConfig ¶
type SwaggerConfig struct { // UIFilePath is the location of folder containing swagger-ui index.html file. e.g. swagger-ui/dist UIFilePath string // UIPrefx is the path where swagger-ui whill be served. e.g. /apidocs UIPrefix string // APIPath is the path where JSON API is available. e.g. /apidocs.json APIPath string // SelfDocEnabled enable the swagger-ui path API in doc. False on default. SelfDocEnabled bool }
SwaggerConfig struct, mirror of swagger.Config