martian

package
v2.16.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2026 License: Apache-2.0, Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const Namespace = "github.com/devopsfaith/krakend-martian"

Namespace is the key to look for extra configuration details

Variables

View Source
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.

func Register

func Register()

Register gets all the modifiers from the krakend-martian register and registers them into the martian parser

Types

type Context

type Context struct {
	context.Context
	// contains filtered or unexported fields
}

Context provides information for a single request/response pair.

func NewContext

func NewContext(parent context.Context) *Context

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

func (c *Context) SkippingRoundTrip() bool

SkippingRoundTrip returns the flag for skipping the round trip

type Result

type Result struct {
	Result *parse.Result
	Err    error
}

Result is a simple wrapper over the parse.FromJSON response tuple

type StaticModifier

type StaticModifier struct {
	*static.Modifier
}

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 (*StaticModifier) ModifyRequest(req *http.Request) error

ModifyRequest marks the context to skip the roundtrip and downgrades any https requests to http.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL