httpx

package
v1.17.4 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultLookupIP added in v1.17.3

func DefaultLookupIP(ctx context.Context, host string) ([]net.IP, error)

func GetClientBaseURL

func GetClientBaseURL(origin, forwardedHost, forwardedProto, host, appURL string) string

GetClientBaseURL determines the client's base URL from request headers. It checks Origin, X-Forwarded-Host/Proto, and Host headers. If none provide a valid URL, it falls back to the configured appURL.

func GetIntQueryParam

func GetIntQueryParam(c *gin.Context, name string, required bool) (int, error)

GetIntQueryParam reads and parses an integer query parameter from the Gin context. If `required` is true and the parameter is missing, or if parsing fails, an error is returned.

func GetQueryParam

func GetQueryParam(c *gin.Context, name string, required bool) (string, error)

GetQueryParam reads a string query parameter from the Gin context. If `required` is true and the parameter is missing or empty, an error is returned.

func NewHTTPClient

func NewHTTPClient() *http.Client

func NewHTTPClientWithTimeout

func NewHTTPClientWithTimeout(timeout time.Duration) *http.Client

func NewSafeOutboundHTTPClient added in v1.17.3

func NewSafeOutboundHTTPClient(base *http.Client, lookupIP LookupIPFunc) (*http.Client, error)

func ValidateSafeRemoteURL added in v1.17.3

func ValidateSafeRemoteURL(ctx context.Context, rawURL string, lookupIP LookupIPFunc) (*url.URL, error)

func ValidateWebSocketOrigin

func ValidateWebSocketOrigin(appURL string) func(r *http.Request) bool

ValidateWebSocketOrigin validates the Origin header for WebSocket connections to prevent CSRF attacks. It checks: 1. Same-origin requests (Origin matches Host) 2. Allowed origins from appURL 3. Handles empty Origin headers (some clients don't send it)

Types

type LookupIPFunc added in v1.17.3

type LookupIPFunc func(ctx context.Context, host string) ([]net.IP, error)

Jump to

Keyboard shortcuts

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