config

package
v0.0.0-...-132b917 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2020 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	FilePath string `json:"file_path"`
	Server   Server `json:"server"`
	Route    Route  `json:"route"`
}

Config represents structure of MicroProxy config.

var Instance *Config

Instance holds reference of singleton Config

func (*Config) Save

func (c *Config) Save(b []byte) (int, error)

Save persists the specified value into the file, as specified on Config.FilePath.

type Destination

type Destination struct {
	ID      string `json:"id"`
	Host    string `json:"host"`
	URL     string `json:"url"`
	Default bool   `json:"default"`
}

Destination represents info of the destination node.

type Route

type Route struct {
	Destinations []Destination `json:"destinations"`
	Rules        []Rule        `json:"rules"`
}

Route represents info required for forwarding request to multiple destinations, based on the specified rules.

func NewRoute

func NewRoute(filePath string) *Route

NewRoute constructs Route based on the given JSON file.

func (*Route) GetDestinationByID

func (r *Route) GetDestinationByID(id string) (*Destination, error)

type Rule

type Rule struct {
	Path          string                 `json:"path"`
	Payload       map[string]interface{} `json:"payload,omitempty"`
	DestinationID string                 `json:"destination_id"`
}

Rule represents info of how the MicroProxy determines routes based on info such as path, and payload.

type Server

type Server struct {
	Port string `json:"port"`
}

Server represets info required for MicroProxy server.

Jump to

Keyboard shortcuts

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