Documentation
¶
Index ¶
- func MatchFixtureQuery(value string) (*regexp.Regexp, bool)
- func ParseArray(params []interface{}, parent string, queryRespMap map[string]gjson.Result) ([]string, error)
- func ParseInterface(params interface{}, queryRespMap map[string]gjson.Result) ([]string, error)
- func ParseMap(params map[string]interface{}, parent string, index int, ...) ([]string, error)
- func ParsePath(httpPath string, queryRespMap map[string]gjson.Result) (string, error)
- func ParseQuery(queryString string, queryRespMap map[string]gjson.Result) (string, error)
- type FixtureQuery
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatchFixtureQuery ¶
MatchFixtureQuery will attempt to find matches for a fixture query pattern returning a *Regexp which can be used to further parse and a boolean indicating a match was found.
func ParseArray ¶
func ParseArray(params []interface{}, parent string, queryRespMap map[string]gjson.Result) ([]string, error)
ParseArray is similar to parseMap but doesn't have to build the multi-depth keys. Form data arrays contain brackets with nothing inside the bracket to designate an array instead of a key value pair.
func ParseInterface ¶
ParseInterface is the primary entrypoint into building the request data for fixtures. The data will always be provided as an interface{} and this will need to use reflection to determine how to proceed. There are two primary paths here, `parseMap` and `ParseArray`, which will recursively traverse and convert the data
This returns an array of clean form data to make the request.
func ParseMap ¶
func ParseMap(params map[string]interface{}, parent string, index int, queryRespMap map[string]gjson.Result) ([]string, error)
ParseMap recursively parses a map of string => interface{} until each leaf node has a terminal type (String, Int, etc) that can no longer be recursively traversed.
func ParsePath ¶
ParsePath will inspect the path to see if it has a query in the path for requests that operate on specific objects (for example, GET /v1/customers/:id or POST /v1/subscriptions/:id)
If a query is found, this returns the path with the value already in place. If there is no query, it returns the old path as-is.
Types ¶
type FixtureQuery ¶
type FixtureQuery struct { Match string // The substring that matched the query pattern regex Name string Query string DefaultValue string }
FixtureQuery describes the query in fixture request
func ToFixtureQuery ¶
func ToFixtureQuery(value string) (FixtureQuery, bool)
ToFixtureQuery will parse a string into a fixtureQuery struct, additionally returning a bool indicating the value did contain a fixtureQuery.