mid

package module
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 2 Imported by: 1

README

mid Go Reference Go Report Card Coverage Status

An extremely mid Go middleware package

Documentation

Overview

Package mid has extremely mid middleware helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller func(w http.ResponseWriter, r *http.Request) http.Handler

Controller implements the pattern in https://choly.ca/post/go-experiments-with-handler/

func (Controller) ServeHTTP

func (c Controller) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Middleware

type Middleware = func(h http.Handler) http.Handler

Middleware is any function that wraps an http.Handler returning a new http.Handler.

type Stack

type Stack []Middleware

Stack is a slice of Middleware.

func (Stack) Clone

func (stack Stack) Clone() Stack

func (Stack) Controller

func (stack Stack) Controller(c Controller) http.Handler

Controller builds an http.Handler that applies all the middleware in the stack before calling c.

func (Stack) Handler

func (stack Stack) Handler(h http.Handler) http.Handler

Handler builds an http.Handler that applies all the middleware in the stack before calling h.

Handler is itself a Middleware.

func (Stack) HandlerFunc

func (stack Stack) HandlerFunc(f http.HandlerFunc) http.Handler

HandlerFunc builds an http.Handler that applies all the middleware in the stack before calling f.

func (*Stack) Push

func (stack *Stack) Push(mw ...Middleware)

Push adds Middleware to end of the stack.

func (*Stack) PushIf

func (stack *Stack) PushIf(cond bool, mw ...Middleware)

PushIf adds Middleware to end of the stack if cond is true.

func (*Stack) With

func (stack *Stack) With(mw ...Middleware) Stack

With clones the stack and pushes to the cloned stack.

Jump to

Keyboard shortcuts

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