Documentation
¶
Index ¶
- Constants
- func Error(w http.ResponseWriter, status int)
- func GetRequestHeaderAPIKey(req *http.Request) string
- func GetRequestHeaderSessionID(req *http.Request) string
- func GetRequestIP(r *http.Request) string
- func NewHTTPClient(opts ...ClientOption) *http.Client
- func NewTransport() http.RoundTripper
- func SetHeaderContentTypeApplicationJSON(w http.ResponseWriter)
- func SetHeaderContentTypeTextHTML(w http.ResponseWriter)
- func SetHeaderRequestID(w http.ResponseWriter, requestID string)
- func SetHeaderRetryAfter(w http.ResponseWriter, retryAfter time.Duration)
- func SetRequestHeaderAPIKey(req *http.Request, apiKey string)
- func SetRequestHeaderSessionID(req *http.Request, sessionID string)
- func WriteJSON(w http.ResponseWriter, status int, data any)
- func WriteNoContent(w http.ResponseWriter)
- func WriteOK(w http.ResponseWriter, data any)
- func WriteRateLimitError(w http.ResponseWriter, err *RateLimitError)
- type ClientOption
- type RateLimitError
Constants ¶
View Source
const ( XForwardedFor = "X-Forwarded-For" XContentTypeOpts = "X-Content-Type-Options" XFrameOpts = "X-Frame-Options" XXSSProtection = "X-Xss-Protection" ReferrerPolicy = "Referrer-Policy" )
View Source
const ( ContentType = "Content-Type" ContentLength = "Content-Length" ContentEncoding = "Content-Encoding" AcceptEncoding = "Accept-Encoding" Vary = "Vary" XRateLimitReason = "X-Ratelimit-Reason" XSessionID = "X-Session-Id" XAPIKey = "X-Api-Key" //nolint:gosec // this is a header name, not a credential )
Variables ¶
This section is empty.
Functions ¶
func Error ¶
func Error(w http.ResponseWriter, status int)
func GetRequestHeaderAPIKey ¶
func GetRequestIP ¶
func NewHTTPClient ¶
func NewHTTPClient(opts ...ClientOption) *http.Client
func NewTransport ¶
func NewTransport() http.RoundTripper
NewTransport returns an http.RoundTripper with standard thoop headers.
func SetHeaderContentTypeApplicationJSON ¶
func SetHeaderContentTypeApplicationJSON(w http.ResponseWriter)
func SetHeaderContentTypeTextHTML ¶
func SetHeaderContentTypeTextHTML(w http.ResponseWriter)
func SetHeaderRequestID ¶
func SetHeaderRequestID(w http.ResponseWriter, requestID string)
func SetHeaderRetryAfter ¶
func SetHeaderRetryAfter(w http.ResponseWriter, retryAfter time.Duration)
func SetRequestHeaderAPIKey ¶ added in v0.0.11
func WriteNoContent ¶
func WriteNoContent(w http.ResponseWriter)
func WriteOK ¶
func WriteOK(w http.ResponseWriter, data any)
func WriteRateLimitError ¶
func WriteRateLimitError(w http.ResponseWriter, err *RateLimitError)
Types ¶
type ClientOption ¶
func WithTimeout ¶
func WithTimeout(d time.Duration) ClientOption
type RateLimitError ¶
func (*RateLimitError) Error ¶
func (e *RateLimitError) Error() string
Click to show internal directories.
Click to hide internal directories.