http

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClientIPMiddleware

func NewClientIPMiddleware(provider Provider) func(next http.Handler) http.Handler

NewClientIPMiddleware returns a middleware function that extracts the client's IP address from the request and adds it to the request's context. The IP address is obtained using the provided IP address provider. The middleware function takes the next http.Handler as input and returns a new http.Handler that wraps the provided handler. When the new handler is called, it first extracts the client's IP address from the request using the provider, adds it to the request's context, and then calls the next handler in the chain. The IP address can be accessed from the request's context using the ClientIP key.

func NewStashMiddleware

func NewStashMiddleware() func(next http.Handler) http.Handler

NewStashMiddleware returns a middleware function that adds a stash to the request context. The stash is a synchronized map that can be used to store and retrieve values during the connection lifecycle. The middleware function takes the next http.Handler as input and returns a new http.Handler that wraps the next handler. The returned handler adds the stash to the request context and then calls the next handler to process the request.

Types

type ContextKey

type ContextKey uint
const (
	NoKey ContextKey = iota
	ClientIP
	Stash
)

type Provider

type Provider uint8
const (
	NotProvided Provider = iota
	Cloudflare
	CloudFront
)

Jump to

Keyboard shortcuts

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