Documentation
¶
Index ¶
- func GetClientBaseURL(origin, forwardedHost, forwardedProto, host, appURL string) string
- func GetIntQueryParam(c *gin.Context, name string, required bool) (int, error)
- func GetQueryParam(c *gin.Context, name string, required bool) (string, error)
- func NewHTTPClient() *http.Client
- func NewHTTPClientWithTimeout(timeout time.Duration) *http.Client
- func ValidateWebSocketOrigin(appURL string) func(r *http.Request) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetClientBaseURL ¶
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 ¶
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 ¶
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 ValidateWebSocketOrigin ¶
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.