Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrProtocolExtraction ¶
type ErrProtocolExtraction struct {
Protocol string
}
ErrProtocolExtraction is returned when we fail to extract a protocol from a request or fail to parse its JSON.
func (ErrProtocolExtraction) Error ¶
func (e ErrProtocolExtraction) Error() string
type Req ¶
type Req map[string]*json.RawMessage
Req is the structure used to make a request to a service
func (Req) ExtractAll ¶
ExtractAll extracts a set of protocols given by the keys of `protocols` from `h`. Protocols are considered optional if they end with a '?' character. For example, the following code would read the protocol "foo" into the variable `a` and the protocol "bar" into the variable `b` if the request contains that protocol. If the "bar" protocol is not specified, `b` will retain its original value "optional".
a := "required" b := "optional" err := req.ExtractAll(map[string]interface{}{ "foo": &a, "bar?": &b, })
This function returns an error if we fail to extract any required protocol.