Documentation
¶
Index ¶
- func AbsoluteRedirectHandle(w http.ResponseWriter, r *http.Request)
- func Base64DecodeHandle(w http.ResponseWriter, r *http.Request)
- func BasicAuthHandle(w http.ResponseWriter, r *http.Request)
- func BearerAuthHandle(w http.ResponseWriter, r *http.Request)
- func BrotliHandle(w http.ResponseWriter, r *http.Request)
- func CookiesHandle(w http.ResponseWriter, r *http.Request)
- func CookiesListHandle(w http.ResponseWriter, r *http.Request)
- func DeflateHandle(w http.ResponseWriter, r *http.Request)
- func DelayHandle(w http.ResponseWriter, r *http.Request)
- func DeleteCookiesHandle(w http.ResponseWriter, r *http.Request)
- func DenyHandle(w http.ResponseWriter, r *http.Request)
- func DigestAuthHandle(w http.ResponseWriter, r *http.Request)
- func DripHandle(w http.ResponseWriter, r *http.Request)
- func GzipHandle(w http.ResponseWriter, r *http.Request)
- func HeadersHandle(w http.ResponseWriter, r *http.Request)
- func HiddenBasicAuthHandle(w http.ResponseWriter, r *http.Request)
- func ImageAcceptHandle(w http.ResponseWriter, r *http.Request)
- func ImageHandle(w http.ResponseWriter, r *http.Request)
- func IpHandle(w http.ResponseWriter, r *http.Request)
- func JsonError(w http.ResponseWriter, err string, code int)
- func LinkPageHandle(w http.ResponseWriter, r *http.Request)
- func LinksHandle(w http.ResponseWriter, r *http.Request)
- func MethodsHandle(w http.ResponseWriter, r *http.Request)
- func NewRouter() *chi.Mux
- func RandomBytesHandle(w http.ResponseWriter, r *http.Request)
- func RangeHandle(w http.ResponseWriter, r *http.Request)
- func RedirectHandle(w http.ResponseWriter, r *http.Request)
- func RedirectToHandle(w http.ResponseWriter, r *http.Request)
- func RelativeRedirectHandle(w http.ResponseWriter, r *http.Request)
- func RobotsHandle(w http.ResponseWriter, r *http.Request)
- func SetCookieHandle(w http.ResponseWriter, r *http.Request)
- func SetCookiesHandle(w http.ResponseWriter, r *http.Request)
- func StreamNMessagesHandle(w http.ResponseWriter, r *http.Request)
- func StreamRandomBytesHandle(w http.ResponseWriter, r *http.Request)
- func TextError(w http.ResponseWriter, err string, code int)
- func UUIDHandle(w http.ResponseWriter, r *http.Request)
- func UserAgentHandle(w http.ResponseWriter, r *http.Request)
- type AuthResponse
- type CookiesListResponse
- type CookiesResponse
- type HeadersResponse
- type IpResponse
- type MethodsResponse
- type StatusResponse
- type StreamResponse
- type UUIDResponse
- type UserAgentResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AbsoluteRedirectHandle ¶ added in v0.8.0
func AbsoluteRedirectHandle(w http.ResponseWriter, r *http.Request)
AbsoluteRedirectHandle is a http handler that makes 302/3XX redirects `n` times. `Location` header is an absolute URL.
func Base64DecodeHandle ¶ added in v0.7.0
func Base64DecodeHandle(w http.ResponseWriter, r *http.Request)
Base64DecodeHandle decodes a base64 encoded string and returns the decoded value
func BasicAuthHandle ¶ added in v0.3.0
func BasicAuthHandle(w http.ResponseWriter, r *http.Request)
BasicAuthHandle prompts the user for authorization using HTTP Basic Auth. It returns 401 if not authorized.
func BearerAuthHandle ¶ added in v0.7.0
func BearerAuthHandle(w http.ResponseWriter, r *http.Request)
BearerAuthHandle prompts the user for authorization using bearer authentication
func BrotliHandle ¶ added in v0.2.0
func BrotliHandle(w http.ResponseWriter, r *http.Request)
BrotliHandle is the handler that returns a response compressed with brotli
func CookiesHandle ¶ added in v0.4.0
func CookiesHandle(w http.ResponseWriter, r *http.Request)
CookiesHandle returns the cookies list, sent by the client
func CookiesListHandle ¶ added in v0.6.0
func CookiesListHandle(w http.ResponseWriter, r *http.Request)
func DeflateHandle ¶ added in v0.2.0
func DeflateHandle(w http.ResponseWriter, r *http.Request)
DeflateHandle is the handler that returns a response compressed with zlib
func DelayHandle ¶ added in v0.3.0
func DelayHandle(w http.ResponseWriter, r *http.Request)
DelayHandle returns the same response as the MethodsHandle, but with a delay
func DeleteCookiesHandle ¶ added in v0.4.0
func DeleteCookiesHandle(w http.ResponseWriter, r *http.Request)
DeleteCookiesHandle deletes the cookies passed in the query parameters, then redirects to /cookies
func DenyHandle ¶ added in v0.8.0
func DenyHandle(w http.ResponseWriter, r *http.Request)
DenyHandle returns a page denied by robots.txt rules.
func DigestAuthHandle ¶ added in v0.7.0
func DigestAuthHandle(w http.ResponseWriter, r *http.Request)
DigestAuthHandle prompts the user for authorization using HTTP Digest Auth.
func DripHandle ¶ added in v0.7.0
func DripHandle(w http.ResponseWriter, r *http.Request)
DripHandle drips data over a duration after an optional initial delay
func GzipHandle ¶ added in v0.2.0
func GzipHandle(w http.ResponseWriter, r *http.Request)
GzipHandle is the handler that returns a response compressed with gzip
func HeadersHandle ¶ added in v0.1.1
func HeadersHandle(w http.ResponseWriter, r *http.Request)
func HiddenBasicAuthHandle ¶ added in v0.7.0
func HiddenBasicAuthHandle(w http.ResponseWriter, r *http.Request)
HiddenBasicAuthHandle prompts the user for authorization using HTTP Basic Auth. It returns 404 if not authorized.
func ImageAcceptHandle ¶ added in v0.9.0
func ImageAcceptHandle(w http.ResponseWriter, r *http.Request)
ImageAcceptHandle returns a simple image of the type suggest by the Accept header
func ImageHandle ¶ added in v0.9.0
func ImageHandle(w http.ResponseWriter, r *http.Request)
func LinkPageHandle ¶ added in v0.7.0
func LinkPageHandle(w http.ResponseWriter, r *http.Request)
LinkPageHandle generates a page containing n links to other pages which do the same.
func LinksHandle ¶ added in v0.7.0
func LinksHandle(w http.ResponseWriter, r *http.Request)
LinksHandle redirects to first links page.
func MethodsHandle ¶ added in v0.1.1
func MethodsHandle(w http.ResponseWriter, r *http.Request)
MethodsHandle is the basic handler for the methods endpoint (GET, POST, PUT, PATCH, DELETE)
func RandomBytesHandle ¶ added in v0.7.0
func RandomBytesHandle(w http.ResponseWriter, r *http.Request)
RandomBytesHandle returns `n` random bytes generated with given `seed`.
func RangeHandle ¶ added in v0.7.0
func RangeHandle(w http.ResponseWriter, r *http.Request)
RangeHandle streams n random bytes generated with given seed, at given chunk size per packet
func RedirectHandle ¶ added in v0.8.0
func RedirectHandle(w http.ResponseWriter, r *http.Request)
RedirectHandle is a http handler that makes 302/3XX redirects `n` times. `n` is a number in the URL path, if `n` is 1, it will redirect to `/get`. if `absolute` query param is true, `Location` header will be an absolute URL.
func RedirectToHandle ¶ added in v0.8.0
func RedirectToHandle(w http.ResponseWriter, r *http.Request)
RedirectToHandle is a http handler that makes 302/3XX redirects to the given URL
func RelativeRedirectHandle ¶ added in v0.8.0
func RelativeRedirectHandle(w http.ResponseWriter, r *http.Request)
RelativeRedirectHandle is a http handler that makes 302/3XX redirects `n` times. `Location` header is a relative URL.
func RobotsHandle ¶ added in v0.2.0
func RobotsHandle(w http.ResponseWriter, r *http.Request)
func SetCookieHandle ¶ added in v0.4.0
func SetCookieHandle(w http.ResponseWriter, r *http.Request)
SetCookieHandle sets a cookie with the name and value passed in the URL path, then redirects to /cookies
func SetCookiesHandle ¶ added in v0.4.0
func SetCookiesHandle(w http.ResponseWriter, r *http.Request)
SetCookiesHandle sets the cookies passed from the query parameters, then redirects to /cookies
func StreamNMessagesHandle ¶ added in v0.3.0
func StreamNMessagesHandle(w http.ResponseWriter, r *http.Request)
StreamNMessagesHandle streams N json messages
func StreamRandomBytesHandle ¶ added in v0.7.0
func StreamRandomBytesHandle(w http.ResponseWriter, r *http.Request)
StreamRandomBytesHandle streams `n` random bytes generated with given `seed`, at given `chunk_size` per packet.
func UUIDHandle ¶ added in v0.7.0
func UUIDHandle(w http.ResponseWriter, r *http.Request)
UUIDHandle returns a new UUID version 4
func UserAgentHandle ¶ added in v0.1.1
func UserAgentHandle(w http.ResponseWriter, r *http.Request)
Types ¶
type AuthResponse ¶ added in v0.3.0
type AuthResponse struct {
Authenticated bool `json:"authenticated"`
User string `json:"user,omitempty"`
Token string `json:"token,omitempty"`
}
AuthResponse is the response for the basic-auth endpoint
type CookiesListResponse ¶ added in v0.6.0
type CookiesResponse ¶ added in v0.4.0
type HeadersResponse ¶ added in v0.1.1
HeadersResponse is the response for the headers endpoint
type IpResponse ¶ added in v0.1.1
type IpResponse struct {
Origin string `json:"origin"`
}
IpResponse is the response for the ip endpoint
type MethodsResponse ¶
type MethodsResponse struct {
// Args is a map of query parameters
Args map[string][]string `json:"args"`
// Data is the raw body of the request
Data string `json:"data"`
// Files is a map of files sent in the request
Files map[string][]string `json:"files"`
// Form is a map of form values sent in the request
Form map[string][]string `json:"form"`
// Headers is a map of headers sent in the request
Headers map[string][]string `json:"headers"`
// JSON is the parsed JSON body of the request
JSON interface{} `json:"json"`
// Origin is the IP address of the requester
Origin string `json:"origin"`
// URL is the full URL of the request
URL string `json:"url"`
// Gzipped is true if the request was compressed with gzip
Gzipped bool `json:"gzipped,omitempty"`
// Brotli is true if the request was compressed with brotli
Brotli bool `json:"brotli,omitempty"`
// Deflated is true if the request was compressed with zlib
Deflated bool `json:"deflated,omitempty"`
}
MethodsResponse is the response for the methods endpoint
type StatusResponse ¶ added in v0.1.1
type StatusResponse struct {
StatusText string `json:"status_text"`
}
StatusResponse is the response for the status endpoint
type StreamResponse ¶ added in v0.3.0
type StreamResponse struct {
// ID is the ID of the message
ID int `json:"id"`
// Args is a map of query parameters
Args map[string][]string `json:"args"`
// Data is the raw body of the request
Headers map[string][]string `json:"headers"`
// Origin is the IP address of the requester
Origin string `json:"origin"`
// URL is the full URL of the request
URL string `json:"url"`
}
StreamResponse represents a response for the stream endpoint
type UUIDResponse ¶ added in v0.7.0
type UUIDResponse struct {
UUID string `json:"uuid"`
}
type UserAgentResponse ¶ added in v0.1.1
type UserAgentResponse struct {
UserAgent string `json:"user-agent"`
}
UserAgentResponse is the response for the user-agent endpoint