defs

package
v0.0.0-...-4f5bba3 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithLogLevel

func WithLogLevel[T MWBaser](l slog.Level) func(h T) error

WithLogLevel is a convenience function to easily write the functional options for each handler.

func WithLogger

func WithLogger[T MWBaser](l *slog.Logger) func(h T) error

WithLogger is a convenience function to easily write the functional options for each handler.

Types

type MWBase

type MWBase struct {
	// contains filtered or unexported fields
}

MWBase contains the basic middleware information common to each midgard handler.

func (*MWBase) Log

func (mw *MWBase) Log() *slog.Logger

Log gets the configured slog.Logger.

func (*MWBase) LogLevel

func (mw *MWBase) LogLevel() slog.Level

LogLevel gets the currently configured log level.

func (*MWBase) Next

func (mw *MWBase) Next() http.Handler

Next gets the next handler in a chain of handlers.

func (*MWBase) SetLog

func (mw *MWBase) SetLog(l *slog.Logger) error

SetLog sets a new slog.Logger to use for logging.

func (*MWBase) SetLogLevel

func (mw *MWBase) SetLogLevel(l slog.Level) error

SetLogLevel sets the new log level to use.

func (*MWBase) SetNext

func (mw *MWBase) SetNext(n http.Handler) error

SetNext sets the next handler for the chain of handlers.

type MWBaser

type MWBaser interface {
	// GetMWBase gets the MWBase structure out of a midgard handler.
	GetMWBase() *MWBase
}

MWBaser is the interface used to get the basic middleware information as defined in MWBase.

type Middleware

type Middleware func(http.Handler) http.Handler

Middleware represents the common type of http middleware. The idea is to have a common interface for all types of middlewares, that is, they get an input handler and return an output handler, that is extended by the middlewares functionality. Customization is done in generator functions, that take parameters to modify the behaviour of the final http.Handler, e.g. methods to allow.

Jump to

Keyboard shortcuts

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