server

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2017 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// SousRouteMap is the configuration of route for the application.
	SousRouteMap = RouteMap{
		{"gdm", "/gdm", &GDMResource{}},
		{"defs", "/defs", &StateDefResource{}},
		{"manifest", "/manifest", &ManifestResource{}},
		{"artifact", "/artifact", &ArtifactResource{}},
		{"status", "/status", &StatusResource{}},
		{"servers", "/servers", &ServerListResource{}},
	}
)

Functions

func New

func New(laddr string, gf GraphFactory) *http.Server

New creates a Sous HTTP server.

func RunServer

func RunServer(v *config.Verbosity, laddr string) error

RunServer starts a server up.

Types

type ArtifactResource

type ArtifactResource struct{}

func (*ArtifactResource) Put

type DELETEManifestHandler

type DELETEManifestHandler struct {
	*sous.State
	*QueryValues
	StateWriter graph.StateWriter
}

DELETEManifestHandler handles DELETE exchanges for manifests

func (*DELETEManifestHandler) Exchange

func (dmh *DELETEManifestHandler) Exchange() (interface{}, int)

Exchange implements Exchanger

type Deleteable

type Deleteable interface {
	Delete() Exchanger
}

Deleteable tags ResourceFamilies that respond to DELETE

type ExchangeFactory

type ExchangeFactory func() Exchanger

An ExchangeFactory builds an Exchanger - they're used to configure the RouteMap

type ExchangeLogger

type ExchangeLogger struct {
	Exchanger Exchanger
	*sous.LogSet
	*http.Request
	httprouter.Params
}

ExchangeLogger wraps and logs the exchange.

func (*ExchangeLogger) Exchange

func (xlog *ExchangeLogger) Exchange() (data interface{}, status int)

Exchange implements Exchanger on ExchangeLogger.

type Exchanger

type Exchanger interface {
	Exchange() (interface{}, int)
}

A Exchanger has an Exchange method - which is presumed to write to an injected ResponseWriter

type GDMHandler

type GDMHandler struct {
	GDM graph.CurrentGDM
}

GDMHandler is an injectable request handler

func (*GDMHandler) Exchange

func (h *GDMHandler) Exchange() (interface{}, int)

Exchange implements the Handler interface

type GDMResource

type GDMResource struct{}

GDMResource is the resource for the GDM

func (*GDMResource) Get

func (gr *GDMResource) Get() Exchanger

Get implements Getable on GDMResource

type GETManifestHandler

type GETManifestHandler struct {
	*sous.State
	*QueryValues
}

GETManifestHandler handles GET exchanges for manifests

func (*GETManifestHandler) Exchange

func (gmh *GETManifestHandler) Exchange() (interface{}, int)

Exchange implements Exchanger

type Getable

type Getable interface {
	Get() Exchanger
}

Getable tags ResourceFamilies that respond to GET

type GraphFactory

type GraphFactory func() Injector

A GraphFactory builds a SousGraph.

type Injector

type Injector interface {
	Inject(...interface{}) error
	Add(...interface{})
}

Injector is an interface for DI systems.

type KV

type KV []string

KV (Key/Value) is a convenience type for PathFor

type ManifestResource

type ManifestResource struct{}

ManifestResource describes resources for manifests

func (*ManifestResource) Delete

func (mr *ManifestResource) Delete() Exchanger

Delete implements Deleteable for ManifestResource

func (*ManifestResource) Get

func (mr *ManifestResource) Get() Exchanger

Get implements Getable for ManifestResource

func (*ManifestResource) Put

func (mr *ManifestResource) Put() Exchanger

Put implements Putable for ManifestResource

type MetaHandler

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

The MetaHandler collects common behavior for route handlers.

func (*MetaHandler) DeleteHandling

func (mh *MetaHandler) DeleteHandling(factory ExchangeFactory) httprouter.Handle

DeleteHandling handles Delete requests.

func (*MetaHandler) ExchangeGraph

func (mh *MetaHandler) ExchangeGraph(w http.ResponseWriter, r *http.Request, p httprouter.Params) Injector

func (*MetaHandler) GetHandling

func (mh *MetaHandler) GetHandling(factory ExchangeFactory) httprouter.Handle

GetHandling handles Get requests.

func (*MetaHandler) HeadHandling

func (mh *MetaHandler) HeadHandling(factory ExchangeFactory) httprouter.Handle

HeadHandling handles Head requests.

func (*MetaHandler) InstallPanicHandler

func (mh *MetaHandler) InstallPanicHandler()

InstallPanicHandler installs an panic handler into the router.

func (*MetaHandler) PutHandling

func (mh *MetaHandler) PutHandling(factory ExchangeFactory) httprouter.Handle

PutHandling handles PUT requests.

type PUTArtifactHandler

type PUTArtifactHandler struct {
	*http.Request
	*QueryValues
	sous.Inserter
}

func (*PUTArtifactHandler) Exchange

func (pah *PUTArtifactHandler) Exchange() (interface{}, int)

type PUTManifestHandler

type PUTManifestHandler struct {
	*sous.State
	*sous.LogSet
	*http.Request
	*QueryValues
	StateWriter graph.StateWriter
}

PUTManifestHandler handles PUT exchanges for manifests

func (*PUTManifestHandler) Exchange

func (pmh *PUTManifestHandler) Exchange() (interface{}, int)

Exchange implements Exchanger

type Putable

type Putable interface {
	Put() Exchanger
}

Putable tags ResourceFamilies that respond to PUT

type QueryValues

type QueryValues struct {
	url.Values
}

QueryValues wrap url.Values to keep them needing to be re-exported

func (*QueryValues) Single

func (qv *QueryValues) Single(field string, def ...string) (string, error)

Single returns a singular value for a query field, or an error if the field is missing (and no default is supplied) or if multiple values are supplied

type Resource

type Resource interface{}

A ResourceFamily bundles up the exchangers that deal with a kind of resources (n.b. that properly, URL == resource, so a URL pattern == many resources

type ResponseWriter

type ResponseWriter struct {
	http.ResponseWriter
}

ResponseWriter wraps the the http.ResponseWriter interface. XXX This is a workaround for Psyringe

type RouteMap

type RouteMap []routeEntry

RouteMap is a list of entries for routing

func (*RouteMap) BuildRouter

func (rm *RouteMap) BuildRouter(grf func() Injector) http.Handler

BuildRouter builds a returns an http.Handler based on some constant configuration

func (*RouteMap) PathFor

func (rm *RouteMap) PathFor(name string, kvs ...KV) (string, error)

PathFor constructs a URL which should route back to the named route, with supplied parameters

type ServerListHandler

type ServerListHandler struct {
	Config *config.Config
}

ServerListHandler handles GET for /servers

func (*ServerListHandler) Exchange

func (slh *ServerListHandler) Exchange() (interface{}, int)

Exchange implements Exchanger on ServerListHandler

type ServerListResource

type ServerListResource struct{}

ServerListResource dispatches /servers

func (*ServerListResource) Get

func (slr *ServerListResource) Get() Exchanger

Get implements Getable on ServerListResource

type StateDefGetHandler

type StateDefGetHandler struct {
	*sous.State
}

func (*StateDefGetHandler) Exchange

func (sdg *StateDefGetHandler) Exchange() (interface{}, int)

type StateDefResource

type StateDefResource struct{}

func (*StateDefResource) Get

func (sdr *StateDefResource) Get() Exchanger

type StatusHandler

type StatusHandler struct {
	GDM          graph.CurrentGDM
	AutoResolver *sous.AutoResolver
	*sous.ResolveFilter
}

StatusHandler handles requests for status.

func (*StatusHandler) Exchange

func (h *StatusHandler) Exchange() (interface{}, int)

Exchange implements the Handler interface.

type StatusMiddleware

type StatusMiddleware struct {
	*sous.LogSet
}

A StatusMiddleware processes panics into 500s and other status codes.

func (*StatusMiddleware) HandlePanic

func (ph *StatusMiddleware) HandlePanic(w http.ResponseWriter, r *http.Request, recovered interface{})

HandlePanic returns a 500 and logs the error. It uses the LogSet provided by the graph.

func (*StatusMiddleware) HandleResponse

func (ph *StatusMiddleware) HandleResponse(status int, r *http.Request, w http.ResponseWriter, data interface{})

HandleResponse returns a 500 and logs the error. It uses the LogSet provided by the graph.

type StatusResource

type StatusResource struct {
}

StatusResource encapsulates a status response.

func (*StatusResource) Get

func (*StatusResource) Get() Exchanger

Get implements Getable on StatusResource.

Jump to

Keyboard shortcuts

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