extensions

package
v0.0.0-...-11dd352 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbortWithStatusJSON

func AbortWithStatusJSON(c *gin.Context, code int, message string)

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:

  1. A time package format string (e.g. time.RFC3339).
  2. 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

func NotFoundHandler(c *gin.Context)

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL