middleware

package
v0.0.0-...-839ea1c Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package middleware contains http.Handler middlewares

Index

Constants

This section is empty.

Variables

View Source
var ErrHighjack = errors.New("hijack not supported")

ErrHighjack error high jack not supported

Functions

func Log

func Log(next http.Handler) http.Handler

Log http Handler captures elapsed time and logs to default slog

func Recover

func Recover(next http.Handler) http.Handler

Recover from a panic

Types

type Global

type Global func(http.Handler) http.Handler

Global defines a Global middleware to apply to a mux

func Stack

func Stack(mws ...Global) Global

Stack returns the stacked list of middlewares

type StatusWriter

type StatusWriter struct {
	http.ResponseWriter
	Status int
}

StatusWriter wrapper around ResponseWriter that keeps track of the HTTP status code and implements http.Hijaker

func (*StatusWriter) Hijack

func (sw *StatusWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)

Hijack implements http.Hijacker

func (*StatusWriter) WriteHeader

func (sw *StatusWriter) WriteHeader(status int)

WriteHeader wraps underlying WriterHeader and keeps http status code

Jump to

Keyboard shortcuts

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