middleware

package
v0.0.0-...-fd9de40 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Auth

func Auth(env *models.Env) func(http.Handler) http.Handler

Auth checks if the request is authenticated.

func CORS

func CORS(next http.Handler) http.Handler

CORS sets the CORS headers.

func Logging

func Logging(env *models.Env) func(http.Handler) http.Handler

Logging logs the incoming HTTP request & its duration.

func NewMemoryCache

func NewMemoryCache(capacity int, ttl time.Duration) (*cache.Client, error)

NewMemoryCache creates a new memory cache and returns

Types

type AppHandler

type AppHandler struct {
	Env     *models.Env
	Handler func(env *models.Env, w http.ResponseWriter, r *http.Request)
}

The Handler struct that takes a configured Env and a function matching our useful signature.

func (*AppHandler) ServeHTTP

func (ah *AppHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP allows your type to satisfy the http.Handler interface.

Jump to

Keyboard shortcuts

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