rproxy

package module
v0.0.0-...-1def2f3 Latest Latest
Warning

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

Go to latest
Published: May 5, 2015 License: MIT Imports: 13 Imported by: 0

README

rproxy

The idea is to have a proxy where host can be registered dynamically. The goal is creating something for development purpose where developers can register their application server and this proxy will send request to correct place.

Usage example for fakedomain.tld

Adding backend node to a server

curl -d 'serverName=fakedomain.tld&targetUrl=http://127.0.0.1:8080' 'http://127.0.0.1:5556/_server/backend'

Show list of servers

curl 'http://127.0.0.1:5556/_server'

Show list of backend node for a server

curl 'http://127.0.0.1:5556/_server/backend?serverName=fakedomain.tld'

Delete a backend node

curl -X DELETE 'http://127.0.0.1:5556/_server/backend?serverName=fakedomain.tld&targetUrl=http://127.0.0.1:8080'

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateReverseProxy

func CreateReverseProxy(target *url.URL) *httputil.ReverseProxy

Types

type Backend

type Backend struct {
	// contains filtered or unexported fields
}

func NewBackend

func NewBackend() *Backend

func (*Backend) ServeHTTP

func (b *Backend) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type BackendNode

type BackendNode struct {
	// contains filtered or unexported fields
}

type Conf

type Conf struct {
	Host      string
	Port      int
	ApiEnable bool
	ApiHost   string
	ApiPort   int
	Servers   []*ServerConfig
}

func DefaultConf

func DefaultConf() *Conf

func LoadConfig

func LoadConfig(filename string) *Conf

func ParseConfig

func ParseConfig(config io.Reader) *Conf

type Proxy

type Proxy struct {
	// contains filtered or unexported fields
}

func NewProxy

func NewProxy(conf *Conf) *Proxy

func (*Proxy) AdminAPI

func (p *Proxy) AdminAPI() *r2router.Seefor

func (*Proxy) ParseServerConfig

func (p *Proxy) ParseServerConfig(req *http.Request) (error, *ServerConfig)

func (*Proxy) Register

func (p *Proxy) Register(serverName, targetUrl string) error

func (*Proxy) RemoveServer

func (p *Proxy) RemoveServer(serverName string) error

func (*Proxy) ServeHTTP

func (p *Proxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)

func (*Proxy) Start

func (p *Proxy) Start()

func (*Proxy) Unregister

func (p *Proxy) Unregister(serverName, targetUrl string) error

type Server

type Server struct {
	// contains filtered or unexported fields
}

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type ServerConfig

type ServerConfig struct {
	ServerName string
	TargetUrl  string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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