Documentation
¶
Index ¶
- func CompressResponseBody(resp *http.Response) error
- func DecompressResponseBody(resp *http.Response) error
- func InjectJsScript(response *http.Response, data io.Reader) (bool, error)
- func ModifyCSP(csp string, scripts ...[]byte) string
- func SessionSave(session sessions.Session, ctx *gin.Context) (success bool)
- func SetContentSecurityHeaders(w http.ResponseWriter, nonce string)
- type ErrorResponse
- type LookupResponse
- type RetryConfig
- type RetryTransport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompressResponseBody ¶
CompressResponseBody compresses the response body using the appropriate compression algorithm.
func DecompressResponseBody ¶
DecompressResponseBody decompresses the response body using the appropriate decompression algorithm.
func InjectJsScript ¶
InjectJsScript injects a JavaScript script into the HTML response body. It injects the script after the <head> tag or before the </body> tag. The location of the script is determined by the first occurrence of the <head> or </body> tag.
func ModifyCSP ¶
ModifyCSP modifies the Content-Security-Policy header to allow the proxy scripts. Furthermore, it whitelists the target hosts specified in ConfigProxyTargetHosts.
func SessionSave ¶
SessionSave saves the session and handles any errors that occur. If an error occurs, it displays an error page and aborts the request. It returns true if the session is saved successfully.
func SetContentSecurityHeaders ¶
func SetContentSecurityHeaders(w http.ResponseWriter, nonce string)
SetContentSecurityHeaders sets the Content-Security-Policy, X-Frame-Options, and X-Content-Type-Options headers. It uses the nonce to set the script-src and style-src directives.
Types ¶
type ErrorResponse ¶ added in v0.0.15
type ErrorResponse struct { Error struct { ErrorCode int `json:"error_code"` ErrorMessage string `json:"error_message"` } `json:"error"` }
ErrorResponse is the response structure for errors from the IP2Location API.
type LookupResponse ¶ added in v0.0.15
type LookupResponse struct { IP string `json:"ip"` CountryCode string `json:"country_code"` CountryName string `json:"country_name"` RegionName string `json:"region_name"` CityName string `json:"city_name"` Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` ZipCode string `json:"zip_code"` TimeZone string `json:"time_zone"` Asn string `json:"asn"` As string `json:"as"` IsProxy bool `json:"is_proxy"` }
LookupResponse is the response structure for the IP2Location API.
func LookupIP ¶ added in v0.0.15
func LookupIP(ip string) (*LookupResponse, error)
LookupIP looks up the IP address using the IP2Location API (https://www.ip2location.io/). It returns geo-location information about the IP address.
type RetryConfig ¶
type RetryConfig struct { MaxRetries int `json:"max_retries,omitempty"` RetryCodes []int `json:"retry_codes,omitempty"` RetryDelay time.Duration `json:"-"` }
RetryConfig is the configuration for the RetryTransport.
func (RetryConfig) MarshalJSON ¶
func (r RetryConfig) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for RetryConfig.
type RetryTransport ¶
type RetryTransport struct { Config RetryConfig http.RoundTripper }
RetryTransport is a custom transport that retries requests on failure.