Documentation ¶
Index ¶
- Constants
- Variables
- func ErrorMessage(c *Context, code int, message string)
- func URLVar(urlvar string) string
- type BufferPool
- type Context
- func (c *Context) AddHeader(key string, value string)
- func (c *Context) ClientIP() string
- func (c *Context) DefaultGet(key interface{}, defaultv interface{}) interface{}
- func (c *Context) DefaultParam(key string, defaultv string) string
- func (c *Context) DefaultQuery(key string, defaultv string) string
- func (c *Context) Error(err error)
- func (c *Context) Errors(err ...error)
- func (c *Context) Get(key interface{}) interface{}
- func (c *Context) GetComplex128(key interface{}) complex128
- func (c *Context) GetFloat64(key interface{}) float64
- func (c *Context) GetHeader(key string) string
- func (c *Context) GetInt64(key interface{}) int64
- func (c *Context) GetString(key interface{}) string
- func (c *Context) JSON(code int, response interface{})
- func (c *Context) MintParam(key string) (interface{}, bool)
- func (c *Context) Next()
- func (c *Context) Param(key string) (string, bool)
- func (c *Context) ParamMap() map[string]string
- func (c *Context) Query(key string) (string, bool)
- func (c *Context) QueryArray(key string) ([]string, bool)
- func (c *Context) QueryValues() url.Values
- func (c *Context) Reset()
- func (c *Context) Set(key, val interface{})
- func (c *Context) SetHeader(key string, value []string)
- func (c *Context) SetMintParam(key string, value interface{})
- func (c *Context) Status(status int)
- func (c *Context) URI() string
- type HandlerContext
- func (hc *HandlerContext) Compressed(isCompressed bool) *HandlerContext
- func (hc *HandlerContext) Handle(handlers ...HandlerFunc) *HandlerContext
- func (hc *HandlerContext) Headers(headers ...string) *HandlerContext
- func (hc *HandlerContext) Methods(methods ...string) *HandlerContext
- func (hc *HandlerContext) Name(name string) *HandlerContext
- func (hc *HandlerContext) Path(path string) *HandlerContext
- func (hc *HandlerContext) Queries(queries ...string) *HandlerContext
- func (hc *HandlerContext) Schemes(schemes ...string) *HandlerContext
- func (hc *HandlerContext) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (hc *HandlerContext) Use(handler ...HandlerFunc) *HandlerContext
- type HandlerFunc
- type Handlers
- type HandlersGroup
- func (hg *HandlersGroup) AddGroup(newhg *HandlersGroup) *HandlersGroup
- func (hg *HandlersGroup) AddGroups(hgs []*HandlersGroup) *HandlersGroup
- func (hg *HandlersGroup) ChainGroups(groups []*HandlersGroup) *HandlersGroup
- func (hg *HandlersGroup) Group(pathPrefix string) *HandlersGroup
- func (hg *HandlersGroup) Handler(hc *HandlerContext) *HandlersGroup
- func (hg *HandlersGroup) Handlers(hsc []*HandlerContext) *HandlersGroup
- func (hg *HandlersGroup) Headers(headers ...string) *HandlersGroup
- func (hg *HandlersGroup) PrefixHandler(hc *HandlerContext)
- func (hg *HandlersGroup) Queries(queries ...string) *HandlersGroup
- func (hg *HandlersGroup) Schemes(schemes ...string) *HandlersGroup
- func (hg *HandlersGroup) SimpleHandler(path string, method string, handler ...HandlerFunc) *HandlerContext
- func (hg *HandlersGroup) Use(handler ...HandlerFunc) *HandlersGroup
- type JSON
- type Logger
- type Mint
- func (mt *Mint) AddGroup(hg *HandlersGroup) *Mint
- func (mt *Mint) AddGroups(hgs []*HandlersGroup) *Mint
- func (mt *Mint) Build() *mux.Router
- func (mt *Mint) ChainGroups(groups []*HandlersGroup) *Mint
- func (mt *Mint) DELETE(path string, handler HandlerFunc) *HandlerContext
- func (mt *Mint) GET(path string, handler HandlerFunc) *HandlerContext
- func (mt *Mint) Get(key string) (interface{}, bool)
- func (mt *Mint) Group(pathPrefix string) *HandlersGroup
- func (mt *Mint) HandleStatic(path string, dir string)
- func (mt *Mint) Handler(hc *HandlerContext) *Mint
- func (mt *Mint) Handlers(hsc []*HandlerContext) *Mint
- func (mt *Mint) MethodNotAllowedHandler(hc *HandlerContext)
- func (mt *Mint) NotFoundHandler(hc *HandlerContext)
- func (mt *Mint) POST(path string, handler HandlerFunc) *HandlerContext
- func (mt *Mint) PUT(path string, handler HandlerFunc) *HandlerContext
- func (mt *Mint) Path(path string) *HandlerContext
- func (mt *Mint) Run(serverAdd string)
- func (mt *Mint) Set(key string, value interface{})
- func (mt *Mint) SimpleHandler(path string, method string, handler ...HandlerFunc) *HandlerContext
- func (mt *Mint) StrictSlash(strictSlash bool) *Mint
- func (mt *Mint) Use(handler ...HandlerFunc)
- type Router
Constants ¶
const (
PayloadKey = "PayLoad"
)
constant
Variables ¶
var ( //DefaultHandlerWithLogger middlewares including logger DefaultHandlerWithLogger = []HandlerFunc{loggerMW} )
Functions ¶
Types ¶
type Context ¶
type Context struct { HandlerContext *HandlerContext Req *http.Request Res http.ResponseWriter // contains filtered or unexported fields }
Context provides context for whole request/response cycle It helps to pass variable from one middlware to another
func (*Context) DefaultGet ¶
func (c *Context) DefaultGet(key interface{}, defaultv interface{}) interface{}
DefaultGet #
func (*Context) DefaultParam ¶
DefaultParam #
func (*Context) DefaultQuery ¶
DefaultQuery #
func (*Context) GetComplex128 ¶
func (c *Context) GetComplex128(key interface{}) complex128
GetComplex128 gets values associated with key as complex128
func (*Context) GetFloat64 ¶
GetFloat64 gets values associated with key as float64
func (*Context) SetMintParam ¶
SetMintParam #
type HandlerContext ¶
type HandlerContext struct { Mint *Mint // contains filtered or unexported fields }
HandlerContext #
func (*HandlerContext) Compressed ¶
func (hc *HandlerContext) Compressed(isCompressed bool) *HandlerContext
Compressed #
func (*HandlerContext) Handle ¶
func (hc *HandlerContext) Handle(handlers ...HandlerFunc) *HandlerContext
Handle #
func (*HandlerContext) Headers ¶
func (hc *HandlerContext) Headers(headers ...string) *HandlerContext
Headers #
func (*HandlerContext) Methods ¶
func (hc *HandlerContext) Methods(methods ...string) *HandlerContext
Methods #
func (*HandlerContext) Queries ¶
func (hc *HandlerContext) Queries(queries ...string) *HandlerContext
Queries #
func (*HandlerContext) Schemes ¶
func (hc *HandlerContext) Schemes(schemes ...string) *HandlerContext
Schemes #
func (*HandlerContext) ServeHTTP ¶
func (hc *HandlerContext) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP #
func (*HandlerContext) Use ¶
func (hc *HandlerContext) Use(handler ...HandlerFunc) *HandlerContext
Use registers middleware
type HandlersGroup ¶
type HandlersGroup struct {
// contains filtered or unexported fields
}
HandlersGroup #
func (*HandlersGroup) AddGroup ¶
func (hg *HandlersGroup) AddGroup(newhg *HandlersGroup) *HandlersGroup
AddGroup add new subgroup
func (*HandlersGroup) AddGroups ¶
func (hg *HandlersGroup) AddGroups(hgs []*HandlersGroup) *HandlersGroup
AddGroups adds new subgroups
func (*HandlersGroup) ChainGroups ¶
func (hg *HandlersGroup) ChainGroups(groups []*HandlersGroup) *HandlersGroup
ChainGroups chains groups in linear
func (*HandlersGroup) Group ¶
func (hg *HandlersGroup) Group(pathPrefix string) *HandlersGroup
Group creates new subgroup
func (*HandlersGroup) Handler ¶
func (hg *HandlersGroup) Handler(hc *HandlerContext) *HandlersGroup
Handler registers new Handler
func (*HandlersGroup) Handlers ¶
func (hg *HandlersGroup) Handlers(hsc []*HandlerContext) *HandlersGroup
Handlers registers chain of handlers
func (*HandlersGroup) Headers ¶
func (hg *HandlersGroup) Headers(headers ...string) *HandlersGroup
Headers #
func (*HandlersGroup) PrefixHandler ¶
func (hg *HandlersGroup) PrefixHandler(hc *HandlerContext)
PrefixHandler registers handler for prefix request
func (*HandlersGroup) Queries ¶
func (hg *HandlersGroup) Queries(queries ...string) *HandlersGroup
Queries #
func (*HandlersGroup) Schemes ¶
func (hg *HandlersGroup) Schemes(schemes ...string) *HandlersGroup
Schemes #
func (*HandlersGroup) SimpleHandler ¶
func (hg *HandlersGroup) SimpleHandler(path string, method string, handler ...HandlerFunc) *HandlerContext
SimpleHandler registers simple handler
func (*HandlersGroup) Use ¶
func (hg *HandlersGroup) Use(handler ...HandlerFunc) *HandlersGroup
Use register new middleware
type Logger ¶
type Logger struct { TimeStamp time.Time StatusCode int Latency time.Duration Method string Path string BodySize int ClientIP string UserName string Errors []error }
Logger logger structure
type Mint ¶
type Mint struct {
// contains filtered or unexported fields
}
Mint is framework's instance, it contains default middleware, DB, handlers configuration Create Intance of Mint using New() method
func (*Mint) AddGroup ¶
func (mt *Mint) AddGroup(hg *HandlersGroup) *Mint
AddGroup adds a group to router
func (*Mint) AddGroups ¶
func (mt *Mint) AddGroups(hgs []*HandlersGroup) *Mint
AddGroups adds a groups of handlers
func (*Mint) ChainGroups ¶
func (mt *Mint) ChainGroups(groups []*HandlersGroup) *Mint
ChainGroups chains groups in linear
func (*Mint) DELETE ¶
func (mt *Mint) DELETE(path string, handler HandlerFunc) *HandlerContext
DELETE register simple delete handler
func (*Mint) GET ¶
func (mt *Mint) GET(path string, handler HandlerFunc) *HandlerContext
GET register get handler
func (*Mint) Group ¶
func (mt *Mint) Group(pathPrefix string) *HandlersGroup
Group creates new group handlers W
func (*Mint) HandleStatic ¶
HandleStatic registers a new handler to handle static content such as img, css, html, js.
func (*Mint) Handler ¶
func (mt *Mint) Handler(hc *HandlerContext) *Mint
Handler registers single handlers context
func (*Mint) Handlers ¶
func (mt *Mint) Handlers(hsc []*HandlerContext) *Mint
Handlers registers multiple handlers context
func (*Mint) MethodNotAllowedHandler ¶
func (mt *Mint) MethodNotAllowedHandler(hc *HandlerContext)
MethodNotAllowedHandler registers method not allowed handler
func (*Mint) NotFoundHandler ¶
func (mt *Mint) NotFoundHandler(hc *HandlerContext)
NotFoundHandler registers not found handler context
func (*Mint) POST ¶
func (mt *Mint) POST(path string, handler HandlerFunc) *HandlerContext
POST registers post handler
func (*Mint) PUT ¶
func (mt *Mint) PUT(path string, handler HandlerFunc) *HandlerContext
PUT register simple PUT handler
func (*Mint) SimpleHandler ¶
func (mt *Mint) SimpleHandler(path string, method string, handler ...HandlerFunc) *HandlerContext
SimpleHandler registers simple handler
func (*Mint) StrictSlash ¶
StrictSlash enable strictslash in router