mapping

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2019 License: MIT Imports: 17 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Set added in v0.6.2

func Set(mappingID string, mapping Mapping) error

Set sets a mapping from its previous value to a new value

func SetAll added in v0.6.2

func SetAll(newMappings []Mapping) error

SetAll sets all the mappings to a current new state

Types

type Injection added in v0.6.0

type Injection struct {
	Headers map[string]string `json:"headers"`
}

Injection represents parameters that can be injected into proxied requests

type Mapping

type Mapping struct {
	Active    bool      `json:"active"`
	Before    string    `json:"before"`
	From      string    `json:"from"`
	Inject    Injection `json:"injection"`
	MappingID string    `json:"mappingID"`
	Origin    string    `json:"origin"`
	Proxy     bool      `json:"proxy"`
	Regexp    string    `json:"regexp"`
	Tags      []string  `json:"tags"`
	To        string    `json:"to"`
}

Mapping represents a mapping that can be active or not

func GetMappings

func GetMappings() ([]Mapping, error)

GetMappings get all mappings or load them if not loaded so far

func (*Mapping) GetVariables added in v0.7.0

func (mapping *Mapping) GetVariables() []variables.Variable

GetVariables returns all the variables set in a mapping

func (*Mapping) Match added in v0.6.2

func (mapping *Mapping) Match(req *http.Request) *MatchResult

Match tests if the mapping matches the specific request. If it does, it will return a match result with the new path where to go. Otherwise it will return nil.

func (*Mapping) Validate added in v0.6.2

func (mapping *Mapping) Validate() error

Validate makes sure that the a mapping is correctly setup

func (Mapping) WithReplacedVariables added in v0.7.0

func (mapping Mapping) WithReplacedVariables(context map[string]string) Mapping

WithReplacedVariables creates a new mapping with all its variables replaced by the values passed in the context

type MatchResult

type MatchResult struct {
	Mapping Mapping
	NewPath string
	Parts   []string
}

MatchResult stores the result for a mapping that matched a request

Jump to

Keyboard shortcuts

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