headers

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Header struct {
	Key   string
	Value string
}

Header type

type RequestInterceptor

type RequestInterceptor struct {
	Intercept func(http.Header)
}

RequestInterceptor intercepts request's headers

func AddRequest

func AddRequest(headerpairs ...string) *RequestInterceptor

AddRequest creates new request interceptor for add headers.

Keys are canonicalized once at construction; the per-request path appends directly to the header map, skipping CanonicalMIMEHeaderKey in http.Header.Add.

func DeleteRequest

func DeleteRequest(headers ...string) *RequestInterceptor

DeleteRequest creates new request interceptor for delete headers.

Keys are canonicalized once at construction so the per-request path can use a direct map delete instead of http.Header.Del, which scans the key through CanonicalMIMEHeaderKey on every call.

func InterceptRequest

func InterceptRequest(f func(http.Header)) *RequestInterceptor

InterceptRequest creates new request interceptor

func MapRequest

func MapRequest(header string, mapper func(string) string) *RequestInterceptor

MapRequest creates new request interceptor for map a header

func SetRequest

func SetRequest(headerpairs ...string) *RequestInterceptor

SetRequest creates new request interceptor for set headers.

Keys are canonicalized once at construction; the per-request path writes directly to the header map, skipping CanonicalMIMEHeaderKey in http.Header.Set. A fresh []string{value} is allocated per request — sharing a pre-built slice would let downstream in-place mutations (e.g. MapRequest) leak across requests.

func (RequestInterceptor) ServeHandler

func (m RequestInterceptor) ServeHandler(h http.Handler) http.Handler

ServeHandler implements middleware interface

type ResponseHeaderWriter added in v0.7.0

type ResponseHeaderWriter interface {
	StatusCode() int
	Header() http.Header
	WriteHeader(statusCode int)
}

ResponseHeaderWriter type

type ResponseInterceptFunc added in v0.7.0

type ResponseInterceptFunc func(w ResponseHeaderWriter)

ResponseInterceptFunc is the function for response's interceptor

type ResponseInterceptor

type ResponseInterceptor struct {
	Intercept ResponseInterceptFunc
}

ResponseInterceptor intercepts response's headers

func AddResponse

func AddResponse(headerpairs ...string) *ResponseInterceptor

AddResponse creates new response interceptor for add headers.

func DeleteResponse

func DeleteResponse(headers ...string) *ResponseInterceptor

DeleteResponse creates new response interceptor for delete headers.

func InterceptResponse

func InterceptResponse(f ResponseInterceptFunc) *ResponseInterceptor

InterceptResponse creates new response interceptor

func MapResponse

func MapResponse(header string, mapper func(string) string) *ResponseInterceptor

MapResponse creates new response interceptor for map a header

func SetResponse

func SetResponse(headerpairs ...string) *ResponseInterceptor

SetResponse creates new response interceptor for set headers.

func (ResponseInterceptor) ServeHandler

func (m ResponseInterceptor) ServeHandler(h http.Handler) http.Handler

ServeHandler implements middleware interface

Jump to

Keyboard shortcuts

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