Documentation ¶
Overview ¶
Package priority allows grouping modifiers and applying them in priority order.
Index ¶
- Variables
- type Group
- func (pg *Group) AddRequestModifier(reqmod martian.RequestModifier, priority int64)
- func (pg *Group) AddResponseModifier(resmod martian.ResponseModifier, priority int64)
- func (pg *Group) ModifyRequest(req *http.Request) error
- func (pg *Group) ModifyResponse(res *http.Response) error
- func (pg *Group) RemoveRequestModifier(reqmod martian.RequestModifier) error
- func (pg *Group) RemoveResponseModifier(resmod martian.ResponseModifier) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrModifierNotFound is the error returned when attempting to remove a // modifier when the modifier does not exist in the group. ErrModifierNotFound = errors.New("modifier not found in group") )
Functions ¶
This section is empty.
Types ¶
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group is a group of request and response modifiers ordered by their priority.
func (*Group) AddRequestModifier ¶
AddRequestModifier adds a RequestModifier with the given priority.
If a modifier is added with a priority that is equal to an existing priority the newer modifier will be added before the existing modifier in the chain.
func (*Group) AddResponseModifier ¶
AddResponseModifier adds a ResponseModifier with the given priority.
If a modifier is added with a priority that is equal to an existing priority the newer modifier will be added before the existing modifier in the chain.
func (*Group) ModifyRequest ¶
ModifyRequest modifies the request. Modifiers are run in descending order of their priority. If an error is returned by a RequestModifier the error is returned and no further modifiers are run.
func (*Group) ModifyResponse ¶
ModifyResponse modifies the response. Modifiers are run in descending order of their priority. If an error is returned by a ResponseModifier the error is returned and no further modifiers are run.
func (*Group) RemoveRequestModifier ¶
RemoveRequestModifier removes the the highest priority given RequestModifier. Returns ErrModifierNotFound if the given modifier does not exist in the group.
func (*Group) RemoveResponseModifier ¶
RemoveResponseModifier removes the the highest priority given ResponseModifier. Returns ErrModifierNotFound if the given modifier does not exist in the group.