Documentation
¶
Index ¶
- func Compose(handler http.Handler, middlewares ...Middleware) http.Handler
- func Create(config Config) http.Handler
- func Etag(handler http.Handler) http.Handler
- func Logger(handler http.Handler) http.Handler
- func Recover(handler http.Handler) http.Handler
- type AppHeaders
- type AuthConfig
- type Config
- type EtagWriter
- type HealthConfig
- type Middleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compose ¶
func Compose(handler http.Handler, middlewares ...Middleware) http.Handler
Compose adds middleware handlers to a given handler.
func Create ¶
Create returns the default middleware composition, useful for all general services. Middleware should be added in a specific order. If any new middleware depends on other middleware, the new middleware should follow afterward.
func Etag ¶
Etag middleware sets the ETag header. Note, this middleware is only useful for buffered response bodies.
Types ¶
type AppHeaders ¶
AppHeaders holds app specific header values
type AuthConfig ¶
type AuthConfig struct {
WhiteList []string
APIKeyName string
SecretKey string
ErrorMessage string
}
AuthConfig holds the necessary values for the authentication middleware
type Config ¶
type Config struct {
Auth bool
AppName string
AppVersion string
Compress bool
EnvVarsToValidate []string
GitRevision string
Handler http.Handler
Region string
SecureOptions secure.Options
WhiteList []string
}
Config holds the values needed for Create()
type EtagWriter ¶ added in v0.1.1
type EtagWriter struct {
http.ResponseWriter
// contains filtered or unexported fields
}
EtagWriter provides a ResponseWriter which holds info needed for verifying etags.
func (*EtagWriter) WriteHeader ¶ added in v0.1.1
func (e *EtagWriter) WriteHeader(status int)
WriteHeader must be defined to override the ResponseWriter's WriteHeader. This is needed to set the etag header in etagWriter.Write, as ResponseWriter's WriteHeader prevents setting headers after it is called.
type HealthConfig ¶
HealthConfig holds the information required by the Health middleware
type Middleware ¶
Middleware represents the function type for all middleware.
func Headers ¶
func Headers(appHeaders AppHeaders) Middleware
Headers adds more app specific headers to the response
func Health ¶
func Health(config HealthConfig) Middleware
Health provides a route to get an app's health information