Documentation
¶
Index ¶
- func AbortWithStatusJSON(c *gin.Context, code int, message string)
- func CORSHandler() gin.HandlerFunc
- func LoggerHandler(logger logrus.FieldLogger, timeFormat string, utc bool) gin.HandlerFunc
- func NoCacheHandler() gin.HandlerFunc
- func NotFoundHandler(c *gin.Context)
- func RequestIDHandler() gin.HandlerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AbortWithStatusJSON ¶
AbortWithStatusJSON is a helper function that calls `Abort()` and then `JSON` internally. This method stops the chain, writes the status code and return a JSON body with HTTP status code and error message. It also sets the Content-Type as "application/json".
func CORSHandler ¶
func CORSHandler() gin.HandlerFunc
CORSHandler returns a gin.HandlerFunc (middleware) to enable CORSHandler support to all origins.
func LoggerHandler ¶
func LoggerHandler(logger logrus.FieldLogger, timeFormat string, utc bool) gin.HandlerFunc
LoggerHandler returns a gin.HandlerFunc (middleware) that logs requests using logrus.
Requests with errors are logged using logrus.Error(). Requests without errors are logged using logrus.Info().
It receives:
- A time package format string (e.g. time.RFC3339).
- A boolean stating whether to use UTC time zone or local.
func NoCacheHandler ¶
func NoCacheHandler() gin.HandlerFunc
NoCacheHandler is a middleware func for setting the Cache-Control to no-cache.
func NotFoundHandler ¶
NotFoundHandler is a helper function that calls server.AbortWithStatusJSON.
func RequestIDHandler ¶
func RequestIDHandler() gin.HandlerFunc
RequestIDHandler injects a special header X-Request-Id to response headers that could be used to track incoming requests for monitoring/debugging purposes.
Types ¶
This section is empty.