httphelpers

package
v1.33.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DrainAndClose

func DrainAndClose(resp *http.Response)

DrainAndClose consumes the remaining response body and closes it to allow connection reuse.

func JoinBasePath added in v1.5.0

func JoinBasePath(basePath, suffix string) string

JoinBasePath ensures the provided suffix is properly joined to the base prefix. The suffix may be relative or absolute and is treated as relative when the base is non-empty.

func NormalizeBasePath added in v1.5.0

func NormalizeBasePath(baseURL string) string

NormalizeBasePath converts a configured base URL into a path prefix that always begins with a leading slash and omits any trailing slash. An empty string indicates the root.

Types

type HostAllowlist added in v1.30.0

type HostAllowlist struct {
	// contains filtered or unexported fields
}

HostAllowlist matches the received HTTP Host against a fixed list.

func NewHostAllowlist added in v1.30.0

func NewHostAllowlist(entries []string) (*HostAllowlist, error)

NewHostAllowlist accepts exact hosts and leading *. subdomain wildcards. An empty list permits all hosts. Invalid entries return an error.

func (*HostAllowlist) Allows added in v1.30.0

func (list *HostAllowlist) Allows(host string) bool

Allows reports whether host, ignoring any port, matches a listed host name or IP.

Jump to

Keyboard shortcuts

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