middleware

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2025 License: Apache-2.0 Imports: 19 Imported by: 2

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

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

func RegisterCacheControl() web.Option

RegisterCacheControl register middleware to set skip cache from request header

func RegisterTenantID

func RegisterTenantID() web.Option

RegisterTenantID register middleware to get tenant id from request header

func RegisterTokenSigner

func RegisterTokenSigner() web.Option

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 CacheControlConfig struct {
	Exclude []string
	Skipper handler.Skipper
}

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

type DomainRequest added in v0.4.0

type DomainRequest interface {
	GetDomain(ctx context.Context, req *auth.GetDomainRequest) (ret *auth.Domain, resp *http.Response, err error)
}

type TenantConfig

type TenantConfig struct {
	Lookup     string
	RootDomain string
	Exclude    []string
	Skipper    handler.Skipper
}

TenantConfig is the configuration for TenantIDMiddleware

Jump to

Keyboard shortcuts

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