Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultAllowHeaders = []string{
"Authorization",
"Content-Length",
"X-CSRF-Token",
"Token",
"Session",
"Accept",
"Origin",
"Host",
"Connection",
"Accept-Encoding",
"Accept-Language",
"DNT",
"Keep-Alive",
"User-Agent",
"X-Requested-With",
"If-Modified-Since",
"Cache-Control",
"Content-Type",
}
View Source
var DefaultAllowMethods = []string{ http.MethodGet, http.MethodPost, http.MethodPut, http.MethodPatch, http.MethodHead, http.MethodHead, http.MethodOptions, http.MethodDelete, }
View Source
var DefaultExposeHeaders = []string{
"Content-Length",
"Access-Control-Allow-Origin",
"Access-Control-Allow-Headers",
"Cache-Control",
"Content-Language",
"Content-Type",
"Expires",
"Last-Modified",
}
Functions ¶
func AccessLog ¶
func AccessLog(skipPaths []string, utc bool, timeFormat string) gin.HandlerFunc
AccessLog 使用ZAP接管GIN相关日志 timeFormat 时间格式 utc 是否使用UTC时间 skipPath 不记录日志的url
func Cors ¶
func Cors(args ...CorsOpt) gin.HandlerFunc
func RecoveryWithZap ¶
func RecoveryWithZap() gin.HandlerFunc
RecoveryWithZap returns a gin.HandlerFunc (middleware) that recovers from any panics and logs requests using uber-go/zap. All errors are logged using zap.Error(). stack means whether output the stack info. The stack info is easy to find where the error occurs but the stack info is too large.
func UseMiddlewares ¶
func UseMiddlewares(engine *gin.Engine, middlewares ...gin.HandlerFunc)
Types ¶
type CorsConfig ¶
Click to show internal directories.
Click to hide internal directories.