middlewares

package
v0.0.5-alpha Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package middlewares provides HTTP middleware functionality for the Zero server. It includes common middleware like CORS, logging, and recovery, as well as utilities for chaining multiple middleware functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chain

func Chain(handler request.Handler, middlewares ...Middleware) request.Handler

Chain applies multiple middleware functions to a handler

Types

type Middleware

type Middleware func(next request.Handler) (handler request.Handler)

Middleware represents a middleware function

func Append

func Append(middlewares []Middleware, middleware Middleware, priority MiddlewarePriority) []Middleware

Append appends a middleware to the chain at the given priority

func CORS

func CORS(allowedOrigins []string) Middleware

CORS middleware adds CORS headers

func Logging

func Logging(logger *slog.Logger) Middleware

Logging middleware logs request details

func Recovery

func Recovery() Middleware

Recovery middleware recovers from panics

type MiddlewarePriority

type MiddlewarePriority int
const (
	// MiddlewarePriorityLow is the lowest priority for a middleware to be executed at the end of the chain
	MiddlewarePriorityLow MiddlewarePriority = iota
	// MiddlewarePriorityHigh is the highest priority for a middleware to be executed at the beginning of the chain
	MiddlewarePriorityHigh
)

Jump to

Keyboard shortcuts

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