config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package config represents the user provided config file structure. Right now with only JSON support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddHeaderRule

type AddHeaderRule struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

AddHeaderRule is a single entry for add-header sections.

type AddRequestCookieRule

type AddRequestCookieRule struct {
	PathMatcher string `json:"path"`
	Name        string `json:"name"`
	Value       string `json:"value"`
}

AddRequestCookieRule is a single entry for add-request-cookie.

type Config

type Config struct {
	Server        Server         `json:"server"`
	Upstream      string         `json:"upstream"`
	DisableTLS    bool           `json:"disableTLSVerify"`
	StaticServers []StaticServer `json:"staticServers"`

	RequestSleepers      []SleepRule            `json:"requestSleepers"`
	RequestDispatchers   []DispatchRule         `json:"requestDispatchers"`
	ResponseModifiers    ResponseModifier       `json:"responseModifiers"`
	ResponseHeaderAdders []AddHeaderRule        `json:"addResponseHeader"`
	RequestCookieAdders  []AddRequestCookieRule `json:"addRequestCookie"`
}

Config represents the whole JSON config file structure.

func Read

func Read(filename string) Config

Read reads the server configs from a .json file

type DispatchDestination

type DispatchDestination struct {
	Server       string `json:"server"`
	Scheme       string `json:"scheme"`
	Host         string `json:"host"`
	PathReplacer string `json:"path"`
	URL          string `json:"url"`
}

DispatchDestination is the destination part of a request dispatcher.

type DispatchRule

type DispatchRule struct {
	PathMatcher string              `json:"path"`
	Destination DispatchDestination `json:"destination"`
}

DispatchRule is a single entry for the request dispatcher section.

type PatchBodyRule

type PatchBodyRule struct {
	Matcher  string `json:"matcher"`
	Replacer string `json:"replacer"`
}

PatchBodyRule is a single entry for the patch body section.

type PatchHeaderRule

type PatchHeaderRule struct {
	Name     string `json:"name"`
	Matcher  string `json:"matcher"`
	Replacer string `json:"replacer"`
}

PatchHeaderRule is a single entry for the modify header section.

type ResponseModifier

type ResponseModifier struct {
	HeaderPatchers []PatchHeaderRule `json:"header"`
	BodyPatchers   []PatchBodyRule   `json:"body"`
}

ResponseModifier TODO

type Server

type Server struct {
	Port   string `json:"port"`
	Scheme string `json:"scheme"`
	Key    string `json:"keyPath"`
	Cert   string `json:"certPath"`
}

Server is the section for the router server itself. Key and Cert are required if Scheme is "https".

type SleepRule added in v0.2.0

type SleepRule struct {
	PathMatcher  string `json:"path"`
	SleepSeconds uint   `json:"seconds"`
}

SleepRule is a single entry for the request sleeper section.

type StaticServer

type StaticServer struct {
	Prefix string `json:"prefix"`
	Root   string `json:"root"`
}

StaticServer is the section for the additional local static file server.

Jump to

Keyboard shortcuts

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