Documentation
¶
Index ¶
- func ConstructURL(domain, path string) string
- func ExtractPathFromURL(fullURL string) string
- func FDPressure() float64
- func FDPressureFrom(current, limit int) float64
- func FDUsage() (current, limit int, err error)
- func GetClientIP(r *http.Request) string
- func IsSignificantRedirect(originalURL, redirectURL string) bool
- func NormaliseDomain(domain string) string
- func NormaliseURL(rawURL string) string
- func SanitiseForJSON(s string) string
- func ValidateDomain(domain string) error
- type RequestMeta
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConstructURL ¶
func ExtractPathFromURL ¶
func FDPressureFrom ¶ added in v0.31.4
Returns 0 (fail-open) when limit <= 0.
func GetClientIP ¶
GetClientIP extracts the client IP address from a request, respecting proxy headers (X-Forwarded-For, X-Real-IP).
func IsSignificantRedirect ¶
IsSignificantRedirect: ignores HTTP↔HTTPS, www↔non-www, default-port and trailing-slash variants — only host/path differences count.
func NormaliseDomain ¶
func NormaliseURL ¶
func SanitiseForJSON ¶
SanitiseForJSON strips control characters (tabs, newlines, etc.) from a string so it can be safely embedded in a JSON value via a Go template. Supabase's email templates render {{ .Data.* }} without JSON-escaping, so any control character in user_metadata breaks the Loops payload.
func ValidateDomain ¶
Types ¶
type RequestMeta ¶
type RequestMeta struct {
IP string
UserAgent string
Browser string
OS string
Device string // e.g. "Chrome on macOS"
City string // From Cloudflare cf-ipcity header
Region string // From Cloudflare cf-region header
Country string // From Cloudflare cf-ipcountry header (ISO code)
Timezone string // From Cloudflare cf-timezone header
Location string // Formatted e.g. "Melbourne, Victoria, Australia"
Timestamp time.Time
}
RequestMeta contains metadata extracted from an HTTP request. Useful for audit logging and contextual email content.
func ExtractRequestMeta ¶
func ExtractRequestMeta(r *http.Request) *RequestMeta
ExtractRequestMeta extracts client metadata from an HTTP request. Location fields (City, Region, Country, Timezone) require the Cloudflare "Add visitor location headers" managed transform to be enabled.
func (*RequestMeta) FormattedTimestamp ¶
func (m *RequestMeta) FormattedTimestamp() string
FormattedTimestamp returns the timestamp in a human-readable format.