vinxi: github.com/vinxi/vinxi/manager Index | Files

package manager

import "github.com/vinxi/vinxi/manager"

Index

Package Files

api.go context.go controller_index.go controller_instances.go controller_plugins.go controller_rules.go controller_scopes.go instance.go manager.go route.go scope.go server.go

Variables

var (
    // DefaultPort stores the default TCP port to listen.
    DefaultPort = 8000

    // DefaultSecurePort stores the default TCP port to listen for secure only connections.
    DefaultSecurePort = 8443

    // DefaultReadTimeout defines the maximum timeout for request read.
    DefaultReadTimeout = 60

    // DefaultWriteTimeout defines the maximum timeout for response write.
    DefaultWriteTimeout = 60
)

func Listen Uses

func Listen(server *http.Server, opts ServerOptions) error

Listen starts listening on the network.

func NewServer Uses

func NewServer(o ServerOptions) *http.Server

NewServer creates a new admin HTTP server.

type Context Uses

type Context struct {
    Manager      *Manager
    Scope        *Scope
    Instance     *Instance
    AdminPlugins *plugin.Layer
    Request      *http.Request
    Response     http.ResponseWriter
    Rule         rule.Rule
    Plugin       plugin.Plugin
}

Context is used to share request context entities across controllers.

func (*Context) ParseBody Uses

func (c *Context) ParseBody(bind interface{}) error

ParseBody parses the body.

func (*Context) Send Uses

func (c *Context) Send(status int, data interface{})

Send is used to serialize and write the response as JSON with custom status code.

func (*Context) SendError Uses

func (c *Context) SendError(status int, message string)

SendError replies with an custom error message and 500 as status code.

func (*Context) SendNoContent Uses

func (c *Context) SendNoContent()

SendNoContent replies with 204 status code.

func (*Context) SendNotFound Uses

func (c *Context) SendNotFound(message string)

SendNotFound replies with 404 status code and custom message.

func (*Context) SendOk Uses

func (c *Context) SendOk(data interface{})

SendOk is used to serialize and write the response as JSON.

type Instance Uses

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

Instance represents the manager instance level.

func NewInstance Uses

func NewInstance(name, description string, proxy *vinxi.Vinxi) *Instance

NewInstance creates a new vinxi manager instance.

func (*Instance) GetScope Uses

func (i *Instance) GetScope(name string) *Scope

GetScope finds and return a registered scope instance.

func (*Instance) HandleHTTP Uses

func (i *Instance) HandleHTTP(w http.ResponseWriter, r *http.Request, next http.Handler)

HandleHTTP is triggered by the vinxi middleware layer on incoming HTTP request.

func (*Instance) ID Uses

func (i *Instance) ID() string

ID returns the instance unique identifier.

func (*Instance) Metadata Uses

func (i *Instance) Metadata() *vinxi.Metadata

Metadata returns the vinxi instance metadata struct.

func (*Instance) NewDefaultScope Uses

func (i *Instance) NewDefaultScope(rules ...rule.Rule) *Scope

NewDefaultScope creates a new default scope.

func (*Instance) NewScope Uses

func (i *Instance) NewScope(name, description string) *Scope

NewScope creates a new scope based on the given name and optional description.

func (*Instance) RemoveScope Uses

func (i *Instance) RemoveScope(name string) bool

RemoveScope removes a registered scope. Returns false if the scope cannot be found.

func (*Instance) Scopes Uses

func (i *Instance) Scopes() []*Scope

Scopes returns the list of registered scopes.

func (*Instance) UseScope Uses

func (i *Instance) UseScope(scopes ...*Scope)

UseScope registers one or multiple scopes at instance level.

type JSONInstance Uses

type JSONInstance struct {
    Info   *vinxi.Metadata `json:"info"`
    Scopes []JSONScope     `json:"scopes"`
}

JSONInstance represents the Instance entity for JSON serialization.

type JSONPlugin Uses

type JSONPlugin struct {
    ID          string        `json:"id"`
    Name        string        `json:"name,omitempty"`
    Description string        `json:"description,omitempty"`
    Enabled     bool          `json:"enabled,omitempty"`
    Config      config.Config `json:"config,omitempty"`
    Metadata    config.Config `json:"metadata,omitempty"`
}

JSONPlugin represents the Plugin entity for JSON serialization.

type JSONRule Uses

type JSONRule struct {
    ID          string        `json:"id"`
    Name        string        `json:"name,omitempty"`
    Description string        `json:"description,omitempty"`
    Config      config.Config `json:"config,omitempty"`
    Metadata    config.Config `json:"metadata,omitempty"`
}

JSONRule represents the Rule entity for JSON serialization.

type JSONScope Uses

type JSONScope struct {
    ID      string       `json:"id"`
    Name    string       `json:"name,omitempty"`
    Rules   []JSONRule   `json:"rules"`
    Plugins []JSONPlugin `json:"plugins"`
}

JSONScope represents the scope entity for JSON serialization.

type Manager Uses

type Manager struct {

    // AdminPlugins stores the HTTP admin server plugins.
    AdminPlugins *plugin.Layer
    // Plugins stores the global plugin layer.
    Plugins *plugin.Layer
    // Server stores the HTTP server used for the admin.
    Server *http.Server
    // Layer stores the manager internal middleware layer.
    Layer *layer.Layer
    // Router stores the manager HTTP router for the admin server.
    Router *httprouter.Router
    // contains filtered or unexported fields
}

Manager represents the vinxi proxy admin manager.

func Manage Uses

func Manage(name, description string, proxy *vinxi.Vinxi) *Manager

Manage creates a new empty manage and starts managing the given vinxi proxy instance.

func New Uses

func New() *Manager

New creates a new manager able to manage and configure multiple vinxi proxy instance.

func (*Manager) GetInstance Uses

func (m *Manager) GetInstance(name string) *Instance

GetInstance finds and returns a vinxi managed instance.

func (*Manager) GetPlugin Uses

func (m *Manager) GetPlugin(name string) plugin.Plugin

GetPlugin finds and returns a plugin by its ID or name.

func (*Manager) GetScope Uses

func (m *Manager) GetScope(name string) *Scope

GetScope finds and returns a vinxi managed instance.

func (*Manager) HandleHTTP Uses

func (m *Manager) HandleHTTP(w http.ResponseWriter, r *http.Request, h http.Handler)

HandleHTTP is triggered by the vinxi middleware layer on incoming HTTP request.

func (*Manager) Instances Uses

func (m *Manager) Instances() []*Instance

Instances returns the registered vinxi instances in the manager.

func (*Manager) ListenAndServe Uses

func (m *Manager) ListenAndServe(opts ServerOptions) (*http.Server, error)

ListenAndServe creates a new admin HTTP server and starts listening on the network based on the given server options.

func (*Manager) Manage Uses

func (m *Manager) Manage(name, description string, proxy *vinxi.Vinxi) *Instance

Manage adds a new vinxi proxy instance to be managed by the current manager instance.

func (*Manager) NewDefaultScope Uses

func (m *Manager) NewDefaultScope(rules ...rule.Rule) *Scope

NewDefaultScope creates a new default scope.

func (*Manager) NewScope Uses

func (m *Manager) NewScope(name, description string) *Scope

NewScope creates a new scope based on the given name and optional description.

func (*Manager) RemoveInstance Uses

func (m *Manager) RemoveInstance(name string) bool

RemoveInstance removes a registered vinxi instance. Returns false if the instance cannot be found.

func (*Manager) RemovePlugin Uses

func (m *Manager) RemovePlugin(id string) bool

RemovePlugin removes a plugin by its ID.

func (*Manager) RemoveScope Uses

func (m *Manager) RemoveScope(name string) bool

RemoveScope removes a registered scope. Returns false if the scope cannot be found.

func (*Manager) Scopes Uses

func (m *Manager) Scopes() []*Scope

Scopes returns the registered scopes at global level.

func (*Manager) ServeDefault Uses

func (m *Manager) ServeDefault() (*http.Server, error)

ServeDefault creates a new admin HTTP server and starts listening on the network based on the default server settings.

func (*Manager) Use Uses

func (m *Manager) Use(handler ...interface{})

Use attaches a new middleware handler for incoming HTTP traffic.

func (*Manager) UseAdminPlugin Uses

func (m *Manager) UseAdminPlugin(plugins ...plugin.Plugin)

UseAdminPlugin registers one or multiple plugins at manager admin level.

func (*Manager) UseFinalHandler Uses

func (m *Manager) UseFinalHandler(fn http.Handler)

UseFinalHandler uses a new middleware handler function as final handler.

func (*Manager) UsePhase Uses

func (m *Manager) UsePhase(phase string, handler ...interface{})

UsePhase attaches a new middleware handler to a specific phase.

func (*Manager) UsePlugin Uses

func (m *Manager) UsePlugin(plugins ...plugin.Plugin)

UsePlugin registers one or multiple plugins at global manager level.

func (*Manager) UseScope Uses

func (m *Manager) UseScope(scopes ...*Scope)

UseScope registers one or multiple scopes at global manager level.

type Route Uses

type Route struct {
    Path    string
    Method  string
    Manager *Manager
    Handler RouteHandler
}

Route represents a route handler.

func (*Route) ServeHTTP Uses

func (c *Route) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.HandlerFunc interface.

type RouteHandler Uses

type RouteHandler func(*Context)

RouteHandler represents HTTP router handler function interface used in routes.

type Scope Uses

type Scope struct {
    // Rules stores the scope registered rules.
    Rules *rule.Layer
    // Plugins provides the plugin register layer.
    Plugins *plugin.Layer
    // ID is used to store the plugin unique identifier.
    ID  string
    // Name is used to store the scope semantic alias.
    Name string
    // Description is used to store the scope human
    // friendly description.
    Description string
}

Scope represents the HTTP configuration scope who can store rules and plugins.

func NewScope Uses

func NewScope(name, description string) *Scope

NewScope creates a new Scope instance with the given name alias and optional description.

func (*Scope) FlushPlugins Uses

func (s *Scope) FlushPlugins()

FlushPlugins removes all the registered plugins.

func (*Scope) FlushRules Uses

func (s *Scope) FlushRules()

FlushRules removes all the registered rules.

func (*Scope) HandleHTTP Uses

func (s *Scope) HandleHTTP(h http.Handler) http.Handler

HandleHTTP is used to trigger the scope layer. If all the rules passes, it will execute the scope specific registered plugins.

func (*Scope) RemovePlugin Uses

func (s *Scope) RemovePlugin(id string) bool

RemovePlugin removes a plugin by its ID.

func (*Scope) RemoveRule Uses

func (s *Scope) RemoveRule(id string) bool

RemoveRule removes a rule by its ID.

func (*Scope) UsePlugin Uses

func (s *Scope) UsePlugin(plugins ...plugin.Plugin)

UsePlugin registers one or multiple plugins in the current scope.

func (*Scope) UseRule Uses

func (s *Scope) UseRule(rules ...rule.Rule)

UseRule registers one or multiple rules in the current scope.

type ServerOptions Uses

type ServerOptions struct {
    Port         int
    ReadTimeout  int
    WriteTimeout int
    Addr         string
    CertFile     string
    KeyFile      string
}

ServerOptions represents the supported server options.

Package manager imports 18 packages (graph). Updated 2016-07-27. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).