http

package
v1.15.3 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 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

This section is empty.

Jump to

Keyboard shortcuts

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