Documentation
¶
Index ¶
- func BindingValue(valueField reflect.Value, rawValue []string, tags reflect.StructTag) error
- type Context
- func (c *Context) Abort()
- func (c *Context) BindingInput(input interface{}) error
- func (c *Context) GetPathParameterAsInt(key string) (int, error)
- func (c *Context) GetPathParameterAsString(key string) string
- func (c *Context) GetQueryInt(key string) (int, error)
- func (c *Context) GetQueryString(key string) string
- func (c *Context) GetQueryStrings(key string) []string
- func (c *Context) HTML(templatePath string, data interface{}) (err error)
- func (c *Context) JSON(data interface{}) (err error)
- func (c *Context) JSONWithStatus(data interface{}, status int) (err error)
- func (c *Context) ParseJson(target interface{}) error
- func (c *Context) ParseXML(target interface{}) error
- func (c *Context) XML(data interface{}) (err error)
- func (c *Context) XMLWithStatus(data interface{}, status int) (err error)
- type Engine
- type FormFile
- type HTMLView
- type JSON
- type JSONParser
- type JsonView
- type Middleware
- type Parser
- type RequestHandler
- type Router
- func (r *Router) AddHandler(pattern string, handler RequestHandler)
- func (r *Router) DELETE(pattern string, handler RequestHandler)
- func (r *Router) GET(pattern string, handler RequestHandler)
- func (r *Router) METHODS(pattern string, methods []string, handler RequestHandler)
- func (r *Router) MakeHandlerContext(writer http.ResponseWriter, request *http.Request, pattern string) *Context
- func (r *Router) PATCH(pattern string, handler RequestHandler)
- func (r *Router) POST(pattern string, handler RequestHandler)
- func (r *Router) PUT(pattern string, handler RequestHandler)
- func (r *Router) Prefix(pattern string, handler RequestHandler)
- func (r *Router) Static(pattern string, staticPath string)
- type RouterMapping
- type View
- type XML
- type XMLParser
- type XMLView
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct {
// Pattern matched url path
Pattern string
// The http.ResponseWriter object.
Writer http.ResponseWriter
// The http.Request object.
Request *http.Request
// Path params
Parameters map[string]string
// For middleware to store dara
Param map[string]interface{}
// contains filtered or unexported fields
}
Context for request
func (*Context) BindingInput ¶
func (*Context) GetPathParameterAsInt ¶
get path parameter as int
func (*Context) GetPathParameterAsString ¶
get path parameter as string
func (*Context) GetQueryInt ¶
get query string as int
func (*Context) GetQueryString ¶
get query string from url
func (*Context) GetQueryStrings ¶
get query string as []string
func (*Context) JSONWithStatus ¶
func (*Context) XMLWithStatus ¶
type Engine ¶
type Engine struct {
Router *Router
Middlewares []Middleware
Logger *logrus.Logger
Cros *cors.Cors
// contains filtered or unexported fields
}
func (*Engine) RunAndListen ¶
func (*Engine) UseMiddleware ¶
func (e *Engine) UseMiddleware(middleware Middleware)
type JSONParser ¶
type JSONParser struct {
}
type Middleware ¶
type Middleware interface {
OnRequest(ctx *Context)
}
type RequestHandler ¶
type RequestHandler func(context *Context)
type Router ¶
type Router struct {
Handlers []RouterMapping
HandlerRouter *mux.Router
Middleware []Middleware
}
func (*Router) AddHandler ¶
func (r *Router) AddHandler(pattern string, handler RequestHandler)
func (*Router) DELETE ¶
func (r *Router) DELETE(pattern string, handler RequestHandler)
func (*Router) GET ¶
func (r *Router) GET(pattern string, handler RequestHandler)
func (*Router) METHODS ¶
func (r *Router) METHODS(pattern string, methods []string, handler RequestHandler)
func (*Router) MakeHandlerContext ¶
func (*Router) PATCH ¶
func (r *Router) PATCH(pattern string, handler RequestHandler)
func (*Router) POST ¶
func (r *Router) POST(pattern string, handler RequestHandler)
func (*Router) PUT ¶
func (r *Router) PUT(pattern string, handler RequestHandler)
func (*Router) Prefix ¶
func (r *Router) Prefix(pattern string, handler RequestHandler)
type RouterMapping ¶
type RouterMapping struct {
Pattern string
HandlerFunc RequestHandler
}
Click to show internal directories.
Click to hide internal directories.