middleware

package
v0.0.0-...-568787c Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a struct that holds registered middlewares and provides methods to run these middlewares on an HTTP handler.

func NewClient

func NewClient(reg Registry, logger log.Logger) *Client

NewClient creates and returns a new Client instance.

func (*Client) Handle

func (mc *Client) Handle(h http.Handler) http.Handler

Handle wraps the provided http.Handler with the registered middlewares and returns the final http.Handler.

type HandlerFunc

type HandlerFunc func(http.Handler) http.Handler

HandlerFunc is a type alias for a function that takes an http.Handler and returns a new http.Handler.

type Middleware

type Middleware interface {
	Handler(logger log.Logger) HandlerFunc
}

Middleware is an interface representing a middleware with a Handler method.

type Registry

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

Registry is a struct that holds a list of registered middlewares.

func GetRegistry

func GetRegistry() *Registry

GetRegistry returns a singleton instance of the Registry.

func (*Registry) GetRegistered

func (r *Registry) GetRegistered() []Middleware

GetRegistered returns a list of registered middlewares.

func (*Registry) Register

func (r *Registry) Register(m Middleware)

Register adds a Middleware to the list of registered middlewares in the Registry.

type StatusMiddleware

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

StatusMiddleware is a struct that holds the health status of the node.

func NewStatusMiddleware

func NewStatusMiddleware(healthStatus *sharedtypes.HealthStatus) *StatusMiddleware

NewStatusMiddleware creates and returns a new Status instance with the given healthStatus.

func (*StatusMiddleware) Handler

func (s *StatusMiddleware) Handler(logger log.Logger) HandlerFunc

Handler returns a MiddlewareFunc that checks the node's health status.

Jump to

Keyboard shortcuts

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