middleware

package module
v0.0.0-...-988d700 Latest Latest
Warning

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

Go to latest
Published: May 13, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Host

func Host(r *http.Request) string

Host gets the first X-Forwarded-Host header from the request

Please use r.Host directly because this value can easily be spoofed and not all reverseProxies set these field

func Origin

func Origin(r *http.Request) string

Origin uses the Proto function and r.Host to give you the origin of the original request

func Proto

func Proto(r *http.Request) string

Proto gets the first X-Forwarded-Proto header from the request Use this to look if the original request was https or http.

In Combination with r.Host You can get the origin of the request like $proto://$r.Host

Types

type Middleware

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

func Forwarded

func Forwarded(trustedProxies int) Middleware

Forwarded looks at the headers of the requests and populates the X-Forwarded-Host and X-Forwarded-Proto values in the context and puts the first trusted X-Forwarded-For value as r.RemoteAddr

Jump to

Keyboard shortcuts

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