Documentation
¶
Index ¶
- func Difference[K comparable, V any](m map[K]V, keys ...K) map[K]V
- func Flatten(m map[string]any, separator string) map[string]any
- func GetKeys[K comparable, V any](maps ...map[K]V) []K
- func GetValues[K comparable, V any](maps ...map[K]V) []V
- func Walk(m map[string]any, callback func(k string, v any))
- type HTTPRequestMap
- type HTTPResponseMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Difference ¶
func Difference[K comparable, V any](m map[K]V, keys ...K) map[K]V
Difference returns the inputted map without the keys specified as input.
func Flatten ¶
Flatten takes a map and returns a new one where nested maps are replaced by dot-delimited keys.
func GetKeys ¶
func GetKeys[K comparable, V any](maps ...map[K]V) []K
GetKeys returns the map's keys.
func GetValues ¶
func GetValues[K comparable, V any](maps ...map[K]V) []V
GetValues returns the map's values.
Types ¶
type HTTPRequestMap ¶
type HTTPRequestMap map[string]interface{}
HTTPRequestMap is a map representation of the request
Example:
{ "request": { "method": "POST", "path": "/foo/bar", "body": "foo=1&bar=test", "raw": "GET /foo/bar?one=testone&two=testtwo HTTP/1.1\nSome-Header: test\n\nfoo=1&bar=test" }, "headers": { "Some-Header": "test" }, "query_params": { "one": "testone", "two": "testtwo" } }
func NewHTTPRequestMap ¶
func NewHTTPRequestMap(req *http.Request) (HTTPRequestMap, error)
func (HTTPRequestMap) Body ¶
func (hrm HTTPRequestMap) Body() string
Body returns request's body as string
func (HTTPRequestMap) Headers ¶
func (hrm HTTPRequestMap) Headers() http.Header
Headers returns all header as http.Header instance
func (HTTPRequestMap) Method ¶
func (hrm HTTPRequestMap) Method() string
Method returns request's method
func (HTTPRequestMap) Path ¶
func (hrm HTTPRequestMap) Path() string
Path returns request's req.URL.Path
func (HTTPRequestMap) QueryParams ¶
func (hrm HTTPRequestMap) QueryParams() url.Values
QueryParams returns all query params as url.Values instance
type HTTPResponseMap ¶
type HTTPResponseMap map[string]interface{}
HTTPResponseMap is a map representation of the response
Example:
{ "request": { "raw": "GET /foo/bar?one=testone&two=testtwo HTTP/1.1\nSome-Header: test\n\nfoo=1&bar=test" }, "response": { "content_length": "2034", "status_code": "200", "body": "<html>....</html>" "raw": "HTTP/2 200 OK\nSome-Header: test\n\n<html>....</html>" }, "headers": { "Some-Header": "test" } }
func NewHTTPResponseMap ¶
func NewHTTPResponseMap(resp *http.Response) (HTTPResponseMap, error)
func (HTTPResponseMap) Body ¶
func (hrm HTTPResponseMap) Body() string
Body returns response's body as string
func (HTTPResponseMap) ContentLength ¶
func (hrm HTTPResponseMap) ContentLength() int
ContentLength returns response's content length
func (HTTPResponseMap) Headers ¶
func (hrm HTTPResponseMap) Headers() http.Header
Headers returns all header as http.Header instance
func (HTTPResponseMap) Response ¶
func (hrm HTTPResponseMap) Response() (*http.Response, error)
Response returns http.Response instance by loading from raw request
func (HTTPResponseMap) StatusCode ¶
func (hrm HTTPResponseMap) StatusCode() int
StatusCode returns response's status code