proxy

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: MIT Imports: 13 Imported by: 8

Documentation

Index

Constants

View Source
const (
	PortEnv       = "ERGO_PORT"
	DomainEnv     = "ERGO_DOMAIN"
	VerboseEnv    = "ERGO_VERBOSE"
	ConfigFileEnv = "ERGO_CONFIG_FILE"

	PortDefault           = "2000"
	DomainDefault         = ".dev"
	ConfigFilePathDefault = "./.ergo"
)

Defines the name of ergo env variable for configuration.

Variables

This section is empty.

Functions

func AddService added in v0.2.0

func AddService(filepath string, service Service) error

AddService adds new service to the filepath

func NewErgoProxy

func NewErgoProxy(config *Config) *httputil.ReverseProxy

NewErgoProxy returns the new reverse proxy.

func RemoveService added in v0.2.2

func RemoveService(filepath string, service Service) error

RemoveService removes a service from the filepath

func ServeProxy added in v0.0.5

func ServeProxy(config *Config) error

ServeProxy listens & serves the HTTP proxy.

Types

type Config

type Config struct {
	Port       string
	Domain     string
	Verbose    bool
	Services   map[string]Service
	ConfigFile string
	// contains filtered or unexported fields
}

Config holds the configuration for the proxy.

func NewConfig added in v0.1.4

func NewConfig() *Config

NewConfig gets the defaults config.

func (*Config) AddService added in v0.2.2

func (c *Config) AddService(service Service) error

AddService add a service using the correct key

func (*Config) GetProxyPacURL added in v0.2.2

func (c *Config) GetProxyPacURL() string

GetProxyPacURL returns the correct url for the pac file

func (*Config) GetService

func (c *Config) GetService(host string) (*Service, error)

GetService gets the service for the given host.

func (*Config) LoadServices added in v0.2.2

func (c *Config) LoadServices() error

LoadServices loads the services from filepath, returns an error if the configuration could not be parsed

func (*Config) OverrideBy added in v0.2.3

func (c *Config) OverrideBy(new *Config)

OverrideBy makes sure that it sets the correct config based on the defaults and the passed by argument

func (*Config) WatchConfigFile added in v0.2.2

func (c *Config) WatchConfigFile(tickerChan <-chan time.Time)

WatchConfigFile listen for file changes and updates the config services

type Service

type Service struct {
	Name string
	URL  *url.URL
}

Service holds the details of the service (Name and URL)

func NewService added in v0.2.0

func NewService(name string, rawURL string) (Service, error)

NewService creates a new service from a name and a URL

func UnsafeNewService added in v0.3.1

func UnsafeNewService(name string, rawURL string) Service

UnsafeNewService creates a new service from a name and a URL without checking if the URL is valid. Must only be used in tests

func (Service) Empty added in v0.2.2

func (s Service) Empty() bool

Empty service means no name or no url

func (Service) GetOriginalURL added in v0.3.1

func (s Service) GetOriginalURL() *url.URL

GetOriginalURL returns the original URL of the service

func (Service) GetServiceURL added in v0.3.1

func (s Service) GetServiceURL(localTLD string) string

GetServiceURL returns the local URL to be used by the proxy server to redirect all request to the service

func (Service) String added in v0.3.1

func (s Service) String() string

String returns a string representation of the service Example:

Service{Name: "test", URL: "http://localhost:8080"}
produces the string "test http://localhost:8080"

Jump to

Keyboard shortcuts

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