Documentation
¶
Overview ¶
Package middleware provides a set of common middleware for use with web application.
It provides the following middleware: gin middleware, gqlgen middleware
Index ¶
- func CacheControlMiddleware(cfg *conf.Configuration) gin.HandlerFunc
- func DomainIDMiddleware(cfg *conf.Configuration, req DomainRequest) gin.HandlerFunc
- func RegisterCacheControl() web.Option
- func RegisterTenantID() web.Option
- func RegisterTokenSigner() web.Option
- func SimplePagination() graphql.ResponseMiddleware
- func TenantIDMiddleware(cfg *conf.Configuration) gin.HandlerFunc
- type CacheControlConfig
- type DomainConfig
- type DomainRequest
- type TenantConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CacheControlMiddleware ¶ added in v0.4.0
func CacheControlMiddleware(cfg *conf.Configuration) gin.HandlerFunc
CacheControlMiddleware returns middleware to set skip cache from request header
func DomainIDMiddleware ¶ added in v0.4.0
func DomainIDMiddleware(cfg *conf.Configuration, req DomainRequest) gin.HandlerFunc
DomainIDMiddleware returns middleware to get domain id from http request
func RegisterCacheControl ¶ added in v0.4.0
RegisterCacheControl register middleware to set skip cache from request header
func RegisterTenantID ¶
RegisterTenantID register middleware to get tenant id from request header
func RegisterTokenSigner ¶
RegisterTokenSigner register middleware to sign request
func SimplePagination ¶
func SimplePagination() graphql.ResponseMiddleware
SimplePagination is a middleware that parses the query string for the simple (similar limit,offset) pagination use it like:
gqlsrv.AroundResponses(gqlx.SimplePagination())
func TenantIDMiddleware ¶
func TenantIDMiddleware(cfg *conf.Configuration) gin.HandlerFunc
TenantIDMiddleware returns middleware to get tenant id from http request
Types ¶
type CacheControlConfig ¶ added in v0.4.0
type DomainConfig ¶ added in v0.4.0
type DomainConfig struct {
// Domains is a map of domain name to domain id
// e.g. {"example.com": 1, "test.com": 2}
// If the domain is not in the map, it will try to get the domain id
// from the auth service using the tenant id from the request context.
Domains map[string]int
Skipper handler.Skipper
// StoreKey is the key to get the cache from the cache manager
// If it is empty, a default cache will be created with size 100000 and
// ttl 5 minutes.
// The cache will be used to store the domain id for the tenant id.
StoreKey string `json:"storeKey" yaml:"storeKey"`
// contains filtered or unexported fields
}
DomainConfig is the configuration for DomainIDMiddleware