Documentation ¶
Index ¶
- Constants
- func ApiTokenMiddleware() gin.HandlerFunc
- func ContentTypeCheckerMiddleware() gin.HandlerFunc
- func CorsHandler(cors *Cors) func(http.Handler) http.Handler
- func GithubMiddleware(secret string) gin.HandlerFunc
- func GzipHandler(compressionLevel int) func(http.Handler) http.Handler
- func JsonHandler() func(http.Handler) http.Handler
- func LogHandler() func(http.Handler) http.Handler
- func LogWithTimingHandler() func(http.Handler) http.Handler
- func RecoveryHandler() func(http.Handler) http.Handler
- func RequestIdMiddleware() gin.HandlerFunc
- func RevisionMiddleware() gin.HandlerFunc
- func SlowMiddleware(maxTime time.Duration, callback SlowHandlerFunc) gin.HandlerFunc
- func TravisCIMiddleware(token string) gin.HandlerFunc
- type Cors
- type Middleware
- type MiddlewareFunc
- type Options
- type SlowHandlerFunc
Constants ¶
const ( BestCompression = gzip.BestCompression BestSpeed = gzip.BestSpeed DefaultCompression = gzip.DefaultCompression NoCompression = gzip.NoCompression )
These compression constants are copied from the compress/gzip package.
const ( RequestIDHeaderKey = "X-Request-Id" ServerHeaderValue = "MessageDB" )
const ApiTokenHeaderKey = "X-MessageDB-Api-Token"
const ContentTypeHeaderKey = "Content-Type"
Variables ¶
This section is empty.
Functions ¶
func ApiTokenMiddleware ¶
func ApiTokenMiddleware() gin.HandlerFunc
func ContentTypeCheckerMiddleware ¶
func ContentTypeCheckerMiddleware() gin.HandlerFunc
func GithubMiddleware ¶
func GithubMiddleware(secret string) gin.HandlerFunc
GithubMiddleware returns a Handler that authenticates via GitHub's Authorization for Webhooks scheme (https://developer.github.com/webhooks/securing/#validating-payloads-from-github) Writes a http.StatusUnauthorized if authentication fails
func GzipHandler ¶
Middleware that sends compresses the response with Gzip if supported by the client
func JsonHandler ¶
Middleware that sends an application/json header
func RequestIdMiddleware ¶
func RequestIdMiddleware() gin.HandlerFunc
func RevisionMiddleware ¶
func RevisionMiddleware() gin.HandlerFunc
func SlowMiddleware ¶
func SlowMiddleware(maxTime time.Duration, callback SlowHandlerFunc) gin.HandlerFunc
func TravisCIMiddleware ¶
func TravisCIMiddleware(token string) gin.HandlerFunc
TravisCI returns a Handler that authenticates via Travis's Authorization for Webhooks scheme (http://docs.travis-ci.com/user/notifications/#Authorization-for-Webhooks) Writes a http.StatusUnauthorized if authentication fails
Types ¶
type Middleware ¶
type Middleware struct {
Chain []MiddlewareFunc
}
func New ¶
func New() *Middleware
func (*Middleware) Handler ¶
func (m *Middleware) Handler() http.Handler
func (*Middleware) UseHandler ¶
func (m *Middleware) UseHandler(handler http.Handler)
type Options ¶
type Options struct { // AllowedOrigins is a list of origins a cross-domain request can be executed from. // If the special "*" value is present in the list, all origins will be allowed. // Default value is ["*"] AllowedOrigins []string // AllowedMethods is a list of methods the client is allowed to use with // cross-domain requests. AllowedMethods []string // AllowedHeaders is list of non simple headers the client is allowed to use with // cross-domain requests. Default value is simple methods (GET and POST) AllowedHeaders []string // ExposedHeaders indicates which headers are safe to expose to the API of a CORS // API specification ExposedHeaders []string // AllowCredentials indicates whether the request can include user credentials like // cookies, HTTP authentication or client side SSL certificates. AllowCredentials bool // MaxAge indicates how long (in seconds) the results of a preflight request // can be cached MaxAge int }
Options is a configuration container to setup the CORS middleware.