Documentation ¶
Index ¶
- Constants
- Variables
- func ConfigGetter(e config.ExtraConfig) interface{}
- func HTTPRequestExecutor(result *parse.Result, re client.HTTPRequestExecutor) client.HTTPRequestExecutor
- func NewBackendFactory(logger logging.Logger, re client.HTTPRequestExecutor) proxy.BackendFactory
- func NewConfiguredBackendFactory(logger logging.Logger, ref func(*config.Backend) client.HTTPRequestExecutor) proxy.BackendFactory
- func Register()
- type Context
- type Result
- type StaticModifier
Constants ¶
const Namespace = "github.com/davron112/krakend-martian"
Namespace is the key to look for extra configuration details
Variables ¶
var ( // ErrEmptyValue is the error returned when there is no config under the namespace ErrEmptyValue = errors.New("getting the extra config for the martian module") // ErrBadValue is the error returned when the config is not a map ErrBadValue = errors.New("casting the extra config for the martian module") // ErrMarshallingValue is the error returned when the config map can not be marshalled again ErrMarshallingValue = errors.New("marshalling the extra config for the martian module") // ErrEmptyResponse is the error returned when the modifier receives a nil response ErrEmptyResponse = errors.New("getting the http response from the request executor") )
Functions ¶
func ConfigGetter ¶
func ConfigGetter(e config.ExtraConfig) interface{}
ConfigGetter implements the config.ConfigGetter interface. It parses the extra config for the martian adapter and returns a Result wrapping the results.
func HTTPRequestExecutor ¶
func HTTPRequestExecutor(result *parse.Result, re client.HTTPRequestExecutor) client.HTTPRequestExecutor
HTTPRequestExecutor creates a wrapper over the received request executor, so the martian modifiers can be executed before and after the execution of the request
func NewBackendFactory ¶
func NewBackendFactory(logger logging.Logger, re client.HTTPRequestExecutor) proxy.BackendFactory
NewBackendFactory creates a proxy.BackendFactory with the martian request executor wrapping the injected one. If there is any problem parsing the extra config data, it just uses the injected request executor.
func NewConfiguredBackendFactory ¶
func NewConfiguredBackendFactory(logger logging.Logger, ref func(*config.Backend) client.HTTPRequestExecutor) proxy.BackendFactory
NewConfiguredBackendFactory creates a proxy.BackendFactory with the martian request executor wrapping the injected one. If there is any problem parsing the extra config data, it just uses the injected request executor.
Types ¶
type Context ¶
Context provides information for a single request/response pair.
func NewContext ¶
NewContext returns a context wrapping the received parent
func (*Context) SkipRoundTrip ¶
func (c *Context) SkipRoundTrip()
SkipRoundTrip flags the context to skip the round trip
func (*Context) SkippingRoundTrip ¶
SkippingRoundTrip returns the flag for skipping the round trip
type StaticModifier ¶
StaticModifier is a martian.RequestResponseModifier that routes reqeusts to rootPath and serves the assets there, while skipping the HTTP roundtrip.
func NewStaticModifier ¶
func NewStaticModifier(rootPath string) *StaticModifier
NewStaticModifier constructs a static.Modifier that takes a path to serve files from, as well as an optional mapping of request paths to local file paths (still rooted at rootPath).
func (*StaticModifier) ModifyRequest ¶
func (s *StaticModifier) ModifyRequest(req *http.Request) error
ModifyRequest marks the context to skip the roundtrip and downgrades any https requests to http.