sandbox

package module
v0.0.0-...-9f7e94e Latest Latest
Warning

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

Go to latest
Published: May 7, 2016 License: MIT Imports: 10 Imported by: 4

README

sandbox Build Status GoDoc Coverage Status

Note: deprecated repository. Source has been merged into vinxi/vinxi.

Sandbox is a vinxi based full-featured, high-level, remotely configurable proxy solution.

Under heavy design progress.

Installation

go get -u gopkg.in/vinxi/sandbox.v0

API

See godoc reference.

Example

TODO

License

MIT

Documentation

Index

Constants

View Source
const Version = "0.1.0"

Version defines the current package semantic version.

Variables

View Source
var (
	// DefaultPort stores the default TCP port to listen.
	DefaultPort = 8080

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

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

Functions

func Listen

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

Listen starts listening on the network.

func NewServer

func NewServer(o ServerOptions) *http.Server

NewServer creates a new admin HTTP server.

Types

type Handler

type Handler func(http.Handler) http.Handler

type JSONPlugin

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

type JSONRule

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

type JSONScope

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

type Layer

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

type Manager

type Manager struct {
	Server *http.Server
	// contains filtered or unexported fields
}

func Manage

func Manage(instance *vinxi.Vinxi) *Manager

func (*Manager) HandleHTTP

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

func (*Manager) NewScope

func (m *Manager) NewScope(rules ...Rule) *Scope

func (*Manager) ServeAndListen

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

type Options

type Options struct {
	Optional bool
}

type Plugin

type Plugin interface {
	// ID is used to retrieve the plugin unique identifier.
	ID() string
	// Name is used to retrieve the plugin name identifier.
	Name() string
	// Description is used to retrieve a human friendly
	// description of what the plugin does.
	Description() string
	// Enable is used to enable the current plugin.
	// If the plugin has been already enabled, the call is no-op.
	Enable()
	// Disable is used to disable the current plugin.
	Disable()
	// Remove is used to disable and remove a plugin.
	// Remove()
	// IsEnabled is used to check if a plugin is enabled or not.
	IsEnabled() bool
	// HandleHTTP is used to run the plugin task.
	// Note: add erro reporting layer
	HandleHTTP(http.Handler) http.Handler
}

Plugin represents the required interface implemented by plugins.

func NewPlugin

func NewPlugin(name, description string, handler Handler) Plugin

type PluginLayer

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

PluginLayer represents a plugins layer designed to intrument proxies providing plugin based dynamic configuration capabilities, such as register/unregister or enable/disable plugins at runtime satefy.

func NewPluginLayer

func NewPluginLayer() *PluginLayer

NewPluginLayer creates a new plugins layer.

func (*PluginLayer) Len

func (l *PluginLayer) Len() int

func (*PluginLayer) Register

func (l *PluginLayer) Register(mw *layer.Layer)

Register implements the middleware Register method.

func (*PluginLayer) Run

func (*PluginLayer) Use

func (l *PluginLayer) Use(plugin Plugin)

type Rule

type Rule interface {
	ID() string
	Name() string
	Description() string
	// Options() Options
	JSONConfig() string
	Match(*http.Request) bool
}

type Scope

type Scope struct {
	ID          string
	Name        string
	Description string
	// contains filtered or unexported fields
}

func NewScope

func NewScope(rules ...Rule) *Scope

func (*Scope) AddRule

func (s *Scope) AddRule(rules ...Rule)

func (*Scope) Disable

func (s *Scope) Disable()

func (*Scope) Enable

func (s *Scope) Enable()

func (*Scope) HandleHTTP

func (s *Scope) HandleHTTP(h http.Handler) func(http.ResponseWriter, *http.Request)

func (*Scope) Rules

func (s *Scope) Rules() []Rule

func (*Scope) UsePlugin

func (s *Scope) UsePlugin(plugin Plugin)

type ServerOptions

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

ServerOptions represents the supported server options.

Directories

Path Synopsis
_examples
plugins

Jump to

Keyboard shortcuts

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