Documentation ¶
Overview ¶
Package parse constructs martian modifiers from JSON messages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ErrUnknownModifier ¶
type ErrUnknownModifier struct {
// contains filtered or unexported fields
}
ErrUnknownModifier is the error returned when the message does not contain a field representing a known modifier type.
func (ErrUnknownModifier) Error ¶
func (e ErrUnknownModifier) Error() string
Error returns a formatted error message for an ErrUnknownModifier.
type ModifierType ¶
type ModifierType string
ModifierType is the HTTP message type.
const ( // Request modifies an HTTP request. Request ModifierType = "request" // Response modifies an HTTP response. Response ModifierType = "response" )
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result holds the parsed modifier and its type.
func FromJSON ¶
FromJSON parses a Modifier JSON message by looking up the named modifier in parseFuncs and passing its modifier to the registered parseFunc. Returns a parse.Result containing the top-level parsed modifier. If no parser has been registered with the given name it returns an error of type ErrUnknownModifier.
func NewResult ¶
func NewResult(mod interface{}, scope []ModifierType) (*Result, error)
NewResult returns a new parse.Result for a given interface{} that implements a modifier and a slice of scopes to generate the result for.
Returns nil, error if a given modifier does not support a given scope
func (*Result) RequestModifier ¶
func (r *Result) RequestModifier() martian.RequestModifier
RequestModifier returns the parsed RequestModifier.
Returns nil if the message has no request modifier.
func (*Result) ResponseModifier ¶
func (r *Result) ResponseModifier() martian.ResponseModifier
ResponseModifier returns the parsed ResponseModifier.
Returns nil if the message has no response modifier.