http

package
v0.2.100 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeJSONBody added in v0.2.41

func DecodeJSONBody(w http.ResponseWriter, r *http.Request, maxBytes int64, dst any) error

DecodeJSONBody reads a JSON document from r.Body into dst, refusing bodies larger than maxBytes and rejecting unknown fields. Use this everywhere instead of a bare json.NewDecoder(r.Body).Decode to avoid memory-exhaustion DoS from untrusted clients.

func DiscoverPattern

func DiscoverPattern(patterns []string, r *http.Request) (string, error)

func GetLang

func GetLang(r *http.Request, defaultLanguage string, languages []language.Tag) (language.Tag, error)

func GetParam

func GetParam(name string, defaultValue string, r *http.Request) string

func GetParamArray

func GetParamArray(name string, defaultValue []string, r *http.Request) []string

func IsSecure added in v0.2.41

func IsSecure(r *http.Request) bool

IsSecure reports whether the request reached us over HTTPS. It returns true when the request hit Go's TLS terminator directly, or when a trusted proxy signals it via X-Forwarded-Proto. Use this — not r.URL.Scheme — when deciding whether to set the Secure attribute on outgoing cookies, because r.URL.Scheme is empty for server-received requests.

func SafeReturnPath added in v0.2.41

func SafeReturnPath(p string) string

SafeReturnPath returns p if it is safe to use as a same-origin redirect target, otherwise "/". Anything that a browser would resolve to a different origin (absolute URLs, scheme-relative "//evil.com" forms, backslash variants used to evade naive prefix checks, non-http schemes) collapses to "/". This is the guard for ?return=… / state= values that get fed into http.Redirect.

func ValidatePattern

func ValidatePattern(pattern string, r *http.Request) (err error)

Types

type Method

type Method string

func MethodFromString

func MethodFromString(method string) Method

func Methods

func Methods() []Method

Jump to

Keyboard shortcuts

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