modules

package
v0.0.0-...-090952a Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2015 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortConfKeys

func SortConfKeys(keys []string) []string

Here to sort conf keys, to keep the module initial in right orders

Types

type BaseModule

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

func (*BaseModule) GetName

func (base *BaseModule) GetName() string

func (*BaseModule) Next

func (base *BaseModule) Next() Module

func (*BaseModule) SetName

func (base *BaseModule) SetName(name string)

func (*BaseModule) SetNext

func (base *BaseModule) SetNext(next Module)

type JSONModule

type JSONModule struct {
	BaseModule
	// contains filtered or unexported fields
}

func NewJSONModule

func NewJSONModule(node Node) *JSONModule

func (*JSONModule) Init

func (m *JSONModule) Init(node Node)

func (*JSONModule) Process

func (m *JSONModule) Process(req *Req, res *Res) bool

type List

type List []Node

func (List) Item

func (l List) Item(idx int) Node

func (List) Len

func (l List) Len() int

type Listener

type Listener struct {
	Address       string
	Servers       map[string]*ServerModule
	DefaultServer *ServerModule
}

func NewListener

func NewListener(addr string) *Listener

func (*Listener) AddServer

func (lsn *Listener) AddServer(server *ServerModule)

func (*Listener) Run

func (lsn *Listener) Run()

func (*Listener) ServeHTTP

func (lsn *Listener) ServeHTTP(writer http.ResponseWriter, request *http.Request)

type Map

type Map map[string]Node

func (Map) Key

func (m Map) Key(key string) Node

func (Map) Keys

func (m Map) Keys() []string

type Module

type Module interface {
	// Init(Node)
	// true to break, false to next
	SetName(string)
	GetName() string
	SetNext(Module)
	Next() Module
	// prcess request and response, return true if processed
	Process(*Req, *Res) bool
}

Relations between module is tree like

func MakeChain

func MakeChain(mp Map) Module

type Node

type Node interface{}

func Child

func Child(root Node, spec string) (Node, error)

func Parse

func Parse(r io.Reader) (Node, error)

func YamlNodeToNode

func YamlNodeToNode(node yaml.Node) Node

type ProxyPassModule

type ProxyPassModule struct {
	BaseModule
}

func NewProxyPassModule

func NewProxyPassModule(node Node) *ProxyPassModule

func (*ProxyPassModule) Process

func (m *ProxyPassModule) Process(req *Req, res *Res) bool

type Req

type Req struct {
	Res *Res
	// contains filtered or unexported fields
}

func (*Req) GetPath

func (req *Req) GetPath() string

type Res

type Res struct {
	Req *Req
	// contains filtered or unexported fields
}

implement http.ResponseWriter

func (*Res) Header

func (res *Res) Header() http.Header

implement http.ResponseWriter

func (*Res) IsProcessed

func (res *Res) IsProcessed() bool

func (*Res) Write

func (res *Res) Write(bytes []byte) (int, error)

implement http.ResponseWriter

func (*Res) WriteHeader

func (res *Res) WriteHeader(status int)

implement http.ResponseWriter

type RootModule

type RootModule struct {
	Upstreams map[string]*UpstreamModule
	Listeners map[string]*Listener
}

func NewRootModule

func NewRootModule(root Node) *RootModule

func (*RootModule) Init

func (root *RootModule) Init(node Node)

func (*RootModule) Run

func (root *RootModule) Run()

type Route

type Route struct {
	Method    string
	Path      string
	PathRegex *regexp.Regexp
	Chain     Module
}

func NewRoute

func NewRoute(node Node) *Route

func (*Route) Init

func (r *Route) Init(node Node)

func (*Route) Match

func (r *Route) Match(req *Req) bool

func (*Route) Process

func (r *Route) Process(req *Req, res *Res) bool

type RoutesModule

type RoutesModule struct {
	BaseModule
	Routes []*Route
}

func NewRoutesModule

func NewRoutesModule(node Node) *RoutesModule

func (*RoutesModule) Init

func (m *RoutesModule) Init(node Node)

func (*RoutesModule) Process

func (m *RoutesModule) Process(req *Req, res *Res) bool

type Scalar

type Scalar string

func (Scalar) GetBool

func (s Scalar) GetBool() bool

func (Scalar) String

func (s Scalar) String() string

type ServerModule

type ServerModule struct {
	Address   string
	Hosts     []string
	IsDefault bool
	Chain     Module
}

func NewServerModule

func NewServerModule(host string, node Node) *ServerModule

func (*ServerModule) Init

func (m *ServerModule) Init(node Node)

Init http modules

func (*ServerModule) Process

func (m *ServerModule) Process(req *Req, res *Res) bool

type SetUrlModule

type SetUrlModule struct {
	BaseModule
}

func NewSetUrlModule

func NewSetUrlModule(node Scalar) *SetUrlModule

func (*SetUrlModule) Process

func (m *SetUrlModule) Process(req *Req, res *Res) bool

type SimpleModule

type SimpleModule struct {
	Modules []Module
}

func (*SimpleModule) GetSubModules

func (sm *SimpleModule) GetSubModules() []Module

func (*SimpleModule) ProcessSubModuels

func (sm *SimpleModule) ProcessSubModuels(req *Req, res *Res) bool

type StaticModule

type StaticModule struct {
	BaseModule
	// contains filtered or unexported fields
}

func NewStaticModule

func NewStaticModule(node Node) *StaticModule

func (*StaticModule) Init

func (m *StaticModule) Init(node Node)

func (*StaticModule) Process

func (m *StaticModule) Process(req *Req, res *Res) bool

type TextModule

type TextModule struct {
	BaseModule
	// contains filtered or unexported fields
}

func NewTextModule

func NewTextModule(node Node) *TextModule

func (*TextModule) Init

func (m *TextModule) Init(node Node)

func (*TextModule) Process

func (m *TextModule) Process(req *Req, res *Res) bool

type UpstreamModule

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

func NewUpstreamModule

func NewUpstreamModule(node Node) *UpstreamModule

func (*UpstreamModule) AddNode

func (up *UpstreamModule) AddNode(node Node)

func (*UpstreamModule) Init

func (up *UpstreamModule) Init(node Node)

Jump to

Keyboard shortcuts

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