Documentation ¶
Overview ¶
statsd middleware
Index ¶
- Constants
- Variables
- func BadRequest(c *gin.Context, data map[string]interface{})
- func CacheControl(c *gin.Context, max int)
- func Cors() gin.HandlerFunc
- func CreateApi(router *gin.Engine, config []Api) *gin.Engine
- func CreateGroup(router *gin.Engine, prefix string, config []Api) *gin.Engine
- func Forbidden(c *gin.Context, data map[string]interface{})
- func JwtClearCookie(c *gin.Context)
- func JwtMiddleWare() gin.HandlerFunc
- func JwtSetCookie(c *gin.Context, v interface{})
- func JwtUserCtx(c *gin.Context, v interface{}) error
- func Logger(headers ...string) gin.HandlerFunc
- func NotFound(c *gin.Context, data map[string]interface{})
- func ServerError(c *gin.Context, data map[string]interface{})
- func StatsdGauge(key string) gin.HandlerFunc
- func StatsdIncrement(key string) gin.HandlerFunc
- func Success(c *gin.Context, data map[string]interface{})
- func Unauthorized(c *gin.Context, data map[string]interface{})
- func UserTrack() gin.HandlerFunc
- type Api
- type ApiHandlers
- type Jwt
- type MyClaims
- type UnlessWare
Constants ¶
View Source
const ( CORS_ALLOW_METHODS string = "GET,HEAD,PUT,PATCH,POST" CORS_ALLOW_HEADERS string = "" )
View Source
const JWT_COOKIE_KEY string = "JWT_TOKEN"
cookie key name
View Source
const JWT_OBJ_KEY string = "user_ctx"
View Source
const USER_TRACK_KEY string = "USER_TRACK"
Variables ¶
View Source
var StatusCode = map[int]string{
100: "Continue",
101: "Switching Protocols",
200: "OK",
201: "Created",
202: "Accepted",
203: "Non-Authoritative Information",
204: "No Content",
205: "Reset Content",
206: "Partial Content",
300: "Multiple Choices",
301: "Moved Permanently",
302: "Found",
303: "See Other",
304: "Not Modified",
305: "Use Proxy",
307: "Temporary Redirect",
400: "Bad Request",
401: "Unauthorized",
402: "Payment Required",
403: "Forbidden",
404: "Not Found",
405: "Method Not Allowed",
406: "Not Acceptable",
407: "Proxy Authentication Required",
408: "Request Time-out",
409: "Conflict",
410: "Gone",
411: "Length Required",
412: "Precondition Failed",
413: "Request Entity Too Large",
414: "Request-URI Too Large",
415: "Unsupported Media Type",
416: "Requested range not satisfiable",
417: "Expectation Failed",
500: "Internal Server Error",
501: "Not Implemented",
502: "Bad Gateway",
503: "Service Unavailable",
504: "Gateway Time-out",
505: "HTTP Version not supported",
}
Functions ¶
func BadRequest ¶
func Cors ¶
func Cors() gin.HandlerFunc
func CreateGroup ¶
create api Group @param prefix [string] api prefix
func JwtUserCtx ¶
read string from cookie, and parse it for user context which stored in v
func ServerError ¶
func StatsdGauge ¶
func StatsdGauge(key string) gin.HandlerFunc
func StatsdIncrement ¶
func StatsdIncrement(key string) gin.HandlerFunc
func Unauthorized ¶
func UserTrack ¶
func UserTrack() gin.HandlerFunc
Types ¶
type Jwt ¶
type Jwt struct { Secret string Domain string Expire int // contains filtered or unexported fields }
Jwt
type MyClaims ¶
type MyClaims struct { Payload string `json:"payload"` jwt.StandardClaims }
custom claim
type UnlessWare ¶
type UnlessWare struct {
// contains filtered or unexported fields
}
func Unless ¶
func Unless(reg string) *UnlessWare
new a Unless ware @Params reg [string] regexp of HTTP Path
func (*UnlessWare) Then ¶
func (that *UnlessWare) Then(fn gin.HandlerFunc) gin.HandlerFunc
if HTTP url matches apiRegexp, then skip fn, otherwise invoke fn. fn can be a middleware or a web controller.
Click to show internal directories.
Click to hide internal directories.