chain

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package chain provides a way to chain multiple http.Handler together.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

type Chain interface {
	ServeHTTP(w http.ResponseWriter, r *http.Request)
	WithStatus(status http.Handler)
}

Chain is a chain of handlers.

func New

func New(final http.Handler, header string, handlers ...ChainHandler) Chain

New creates a new chain.

type ChainHandler

type ChainHandler interface {
	ServeHTTP(w http.ResponseWriter, r *http.Request) (*Status, error)
}

ChainHandler is a handler that can be chained.

type Status

type Status struct {
	// Return is a flag that tells the chain to return. If Return is true, the
	// chain will return a 403 (e.g., the ip is in the denylist)
	Return bool
	// Break is a flag that tells the chain to break. If Break is true, the chain
	// will stop (e.g., the ip is in the allowlist)
	Break bool
}

Status is a status that can be returned by a handler.

Jump to

Keyboard shortcuts

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