Documentation ¶
Index ¶
- func CreateToken(key []byte, payloadData any) (string, error)
- type Context
- func (c *Context) Abort()
- func (c *Context) Binary() ([]byte, error)
- func (c *Context) BindJson(obj any) (any, error)
- func (c *Context) ClientIp() string
- func (c *Context) Data(code int, contentType string, data []byte)
- func (c *Context) Extra(key string) any
- func (c *Context) Fail(code int, err string)
- func (c *Context) FormData(key string) string
- func (c *Context) FormFile(key string) (multipart.File, *multipart.FileHeader, error)
- func (c *Context) GetHeader(key string) string
- func (c *Context) HTML(code int, name string, data interface{})
- func (c *Context) JSON(code int, obj any)
- func (c *Context) Next()
- func (c *Context) Param(key string) string
- func (c *Context) Query(key string) string
- func (c *Context) SetExtra(key string, v any)
- func (c *Context) SetHeader(key string, value string)
- func (c *Context) Status(code int)
- func (c *Context) String(code int, format string, values ...any)
- type DELETE
- type Engine
- type GET
- type H
- type HEAD
- type Handler
- type HandlerFunc
- type JWT
- type JWTDefaultParams
- type Listener
- type OPTIONS
- type PATCH
- type POST
- type PUT
- type RouterGroup
- func (group *RouterGroup) Bind(listeners ...Listener)
- func (group *RouterGroup) DELETE(pattern string, handler Handler)
- func (group *RouterGroup) GET(pattern string, handler Handler)
- func (group *RouterGroup) Group(prefix string) *RouterGroup
- func (group *RouterGroup) HEAD(pattern string, handler Handler)
- func (group *RouterGroup) OPTIONS(pattern string, handler Handler)
- func (group *RouterGroup) PATCH(pattern string, handler Handler)
- func (group *RouterGroup) POST(pattern string, handler Handler)
- func (group *RouterGroup) PUT(pattern string, handler Handler)
- func (group *RouterGroup) REQUEST(method, pattern string, handler Handler)
- func (group *RouterGroup) Static(relativePath string, root string)
- func (group *RouterGroup) Use(middlewares ...Handler) *RouterGroup
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct { // origin objects Writer http.ResponseWriter Request *http.Request // request info Path string Method string // response info StatusCode int // contains filtered or unexported fields }
func (*Context) Abort ¶
func (c *Context) Abort()
Abort is used in middleware, it means stopping the current middleware
func (*Context) Next ¶
func (c *Context) Next()
Next is used in middleware, it means executing the next middleware or handle
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine implement the interface of ServeHTTP
type Handler ¶
type Handler interface {
Handle(*Context)
}
Handler defines the request handler used by web
func JwtConfirm ¶
JwtConfirm is a middleware which defines to check the verification of jwt
func RateLimit ¶
RateLimit is a middleware which limits the frequency of access to the same IP address
type HandlerFunc ¶
type HandlerFunc func(*Context)
HandlerFunc realizes the Handler
func (HandlerFunc) Handle ¶
func (f HandlerFunc) Handle(ctx *Context)
type JWTDefaultParams ¶
type RouterGroup ¶
type RouterGroup struct {
// contains filtered or unexported fields
}
func (*RouterGroup) Bind ¶
func (group *RouterGroup) Bind(listeners ...Listener)
Bind is defined to bind all listeners to the router
func (*RouterGroup) DELETE ¶
func (group *RouterGroup) DELETE(pattern string, handler Handler)
DELETE defines the method to add DELETE request
func (*RouterGroup) GET ¶
func (group *RouterGroup) GET(pattern string, handler Handler)
GET defines the method to add GET request
func (*RouterGroup) Group ¶
func (group *RouterGroup) Group(prefix string) *RouterGroup
Group is defined to create a new RouterGroup remember all groups share the same Engine instance
func (*RouterGroup) HEAD ¶
func (group *RouterGroup) HEAD(pattern string, handler Handler)
HEAD defines the method to add HEAD request
func (*RouterGroup) OPTIONS ¶
func (group *RouterGroup) OPTIONS(pattern string, handler Handler)
OPTIONS defines the method to add OPTIONS request
func (*RouterGroup) PATCH ¶
func (group *RouterGroup) PATCH(pattern string, handler Handler)
PATCH defines the method to add PATCH request
func (*RouterGroup) POST ¶
func (group *RouterGroup) POST(pattern string, handler Handler)
POST defines the method to add POST request
func (*RouterGroup) PUT ¶
func (group *RouterGroup) PUT(pattern string, handler Handler)
PUT defines the method to add PUT request
func (*RouterGroup) REQUEST ¶
func (group *RouterGroup) REQUEST(method, pattern string, handler Handler)
REQUEST defines your method to request
func (*RouterGroup) Static ¶
func (group *RouterGroup) Static(relativePath string, root string)
Static is defined to map local static resources
func (*RouterGroup) Use ¶
func (group *RouterGroup) Use(middlewares ...Handler) *RouterGroup
Use is defined to add middleware to the group
type Server ¶
type Server struct { *RouterGroup // contains filtered or unexported fields }
func Default ¶
func Default() *Server
Default is the constructor of web.Server with Recovery and Logger