Documentation ¶
Overview ¶
Package common provides some utility functions for dealing with HTTP requests and responses
Index ¶
- func ArraysToMaps(in interface{}) interface{}
- func Filter(in interface{}, path string) (interface{}, error)
- func ForceStringKeys(in interface{}) interface{}
- func MakeRequest(method string, url string, input io.Reader, headersIncluded bool) (*http.Response, error)
- func Munge(left, right interface{}) interface{}
- func MungeWithFilter(left, right interface{}, f FilterFunc) interface{}
- func SortedKeys(in interface{}) []interface{}
- func WriteRequest(w io.Writer, req *http.Request, includeMethod bool, includeUrl bool, ...) error
- func WriteResponse(w io.Writer, resp *http.Response, includeHeaders bool, includeStatus bool) error
- type FilterFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArraysToMaps ¶
func ArraysToMaps(in interface{}) interface{}
ArraysToMaps creates a copy of the provided interface{}, with all arrays converted into maps where the keys are the array indices, starting at 0. This is useful for formatters where the target serialisation format does not have a means of representing arrays
func Filter ¶
Filter takes structured data and returns just the portion of it that matches the provided path using dot notation. The path may contain asterisks, in which case all entries will match at that level of the path e.g. products.*.id will return all product ids
func ForceStringKeys ¶
func ForceStringKeys(in interface{}) interface{}
ForceStringKeys creates a copy of the provided interface{}, with all maps changed to have string keys for use by serialisers that expect string keys This is useful for formatters where the target serialisation format only allows string keys
func MakeRequest ¶
func MakeRequest(method string, url string, input io.Reader, headersIncluded bool) (*http.Response, error)
MakeRequest performs an HTTP request based on the information provided
func MungeWithFilter ¶
func MungeWithFilter(left, right interface{}, f FilterFunc) interface{}
func SortedKeys ¶
func SortedKeys(in interface{}) []interface{}