mapping

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2018 License: MIT Imports: 15 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetStatus

func SetStatus(mappingID string, status bool) error

SetStatus change the status of a mapping and save the new state to disk so that it will get loaded on next start

Types

type DynamicMapping

type DynamicMapping struct {
	Active    bool      `json:"active"`
	From      string    `json:"from"`
	Inject    Injection `json:"injection"`
	MappingID string    `json:"mappingID"`
	Origin    string    `json:"origin"`
	Proxy     bool      `json:"proxy"`
	Regexp    string    `json:"regexp"`
	To        string    `json:"to"`
}

DynamicMapping represents a mapping that can be active or not

func GetMappings

func GetMappings() ([]DynamicMapping, error)

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

func (*DynamicMapping) Match

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

Match tests if the mapping matches the specific request. If it does, it will return a match result, otherwise it will return nil.

func (*DynamicMapping) Validate added in v0.6.0

func (mapping *DynamicMapping) Validate() error

Validate makes sure that the a mapping is correctly setup

type Injection added in v0.6.0

type Injection struct {
	Headers map[string]string
}

Injection represents parameters that can be injected into proxied requests

type Mapping

type Mapping struct {
	From      string    `json:"from"`
	Inject    Injection `json:"inject"`
	MappingID string    `json:"mappingID"`
	Origin    string    `json:"origin"`
	Proxy     bool      `json:"proxy"`
	Regexp    string    `json:"regexp"`
	To        string    `json:"to"`
}

Mapping represents a mapping configuration loaded from some file.

type MatchResult

type MatchResult struct {
	Mapping DynamicMapping
	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