Documentation ¶
Index ¶
- func ListenFor(hash bool, pattern string, fx func(PushEvent), fail func(PushEvent))
- func ReadBody(res *http.Response) ([]byte, error)
- func URIMatcher(path string) pattern.URIMatcher
- func WrapHandler(fx func()) func(PushEvent)
- func WrapParams(params Params) string
- type BasicHTTPHandler
- type ErrorHandler
- type HTTPCacheHandler
- type HTTPHandler
- type HandleMux
- type Handler
- type Multiplexer
- type Mux
- type NilServer
- type Params
- type PreprocessHandler
- type PushDirectiveEvent
- type PushEvent
- type PushEventHandler
- type PushEventNotification
- type PushEventSubscriber
- type Resolvable
- type ResolveMorpher
- type Resolver
- type RouteApplier
- type RouteManager
- type Router
- func (r *Router) Cache() cache.Cache
- func (r *Router) Delete(path string, params Params) (*http.Response, error)
- func (r *Router) Do(method string, path string, params Params, body io.ReadCloser) (*http.Response, error)
- func (r *Router) Get(path string, params Params) (*http.Response, error)
- func (r *Router) Head(path string, params Params) (*http.Response, error)
- func (r *Router) Options(path string, params Params) (*http.Response, error)
- func (r *Router) Patch(path string, params Params, body io.ReadCloser) (*http.Response, error)
- func (r *Router) Post(path string, params Params, body io.ReadCloser) (*http.Response, error)
- func (r *Router) Put(path string, params Params, body io.ReadCloser) (*http.Response, error)
- type Routing
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenFor ¶
ListenFor takes the giving pattern, matches it against changes provided by the current PathObserver, if the full URL(i.e Path+Hash) matches then fires the provided function.
func URIMatcher ¶
func URIMatcher(path string) pattern.URIMatcher
URIMatcher returns a new uri matcher if it has not being already creatd.
func WrapHandler ¶
func WrapHandler(fx func()) func(PushEvent)
WrapHandler returns a function of type PathHandler by wrapping the provided no argument function in one.
func WrapParams ¶
WrapParams transforms the params map into a string of &key=value pair.
Types ¶
type BasicHTTPHandler ¶
type BasicHTTPHandler interface {
ServeHTTP(http.ResponseWriter, *http.Request) error
}
BasicHTTPHandler defines a request interface which defines a type which will be used to service a http request.
type ErrorHandler ¶
type ErrorHandler struct {
Handler BasicHTTPHandler
}
ErrorHandler defines a new HTTPHandler which is used to service a request and respond to a giving error that occurs.
func (ErrorHandler) ServeHTTP ¶
func (e ErrorHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP services the incoming request to the underline Handler supplied for the basic handler.
type HTTPCacheHandler ¶
HTTPCacheHandler defines a handler which implements a type which allows a handler to have access to a current request and response with the underline cache being used.
type HTTPHandler ¶
type HTTPHandler interface {
ServeHTTP(http.ResponseWriter, *http.Request)
}
HTTPHandler defines a request interface which defines a type which will be used to service a http request.
func NewErrorHandler ¶
func NewErrorHandler(bh BasicHTTPHandler) HTTPHandler
NewErrorHandler returns a new instance of the HTTPHandler which is used to service a request and respond to a giving error that occurs.
type HandleMux ¶
type HandleMux struct {
// contains filtered or unexported fields
}
HandleMux defines a structure which handles the variaties in the supported request handlers of the router package and encapsulates the needed behaviour calls.
func NewHandleMux ¶
func NewHandleMux(handler interface{}) HandleMux
NewHandleMux returns a new instance of a HandleMux.
type Handler ¶
type Handler func(PushEvent)
Handler defines a function type for a Resolver subcriber.
type Multiplexer ¶
type Multiplexer struct {
// contains filtered or unexported fields
}
Multiplexer defines a struct which manages giving set of Mux and adequates calls the first to match a giving request about a incoming request.
func NewMultiplexer ¶
func NewMultiplexer(mx ...Mux) Multiplexer
NewMultiplexer returns a new instance of a Multiplexer.
func (Multiplexer) Match ¶
func (m Multiplexer) Match(path string) (string, HTTPCacheHandler, error)
Match examines the path and returns a new path, a Mux to handle the request else returns an error if one is not found.
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
Mux defines a structure which giving a Matcher and a handler which implements either the HTTPCacheHandler/BasicHandler/HTTPHandler and also optionally the PreprocessorHandler, where request being serviced will receive a new path when called and will be used to define, which part an external service will use to service a incoming relative path request. Below is demonstrated a scenario where Mux can be used for to handle request for specific namespace. Scenrio:
Mux has URI Matcher for github/*
When:
Mux receives request for github/gu-io/buba
If Mux has Preprocessor to to transform path to github.com/path:
Then: Path returned is github.com/gu-io/buba
If Mux has No Preprocessor
Then: Path returned is gu-io/buba.
type NilServer ¶
type NilServer struct{}
NilServer defines a empty struct implementing the http.Handler interface.
type PreprocessHandler ¶
PreprocessHandler exposes a type which implements both the http.Handler and a method which pre-processes giving routes for use in a request.
type PushDirectiveEvent ¶
type PushDirectiveEvent struct {
To string
}
PushDirectiveEvent defines a event which is used to declare the switching of the route to another path provided.
type PushEvent ¶
type PushEvent struct { Host string Hash string Path string Rem string To string From string Params map[string]string }
PushEvent represent the current path and hash values.
@notification:event
func NewPushEvent ¶
NewPushEvent returns PushEvent based on the path string provided.
func UseLocation ¶
UseLocation returns the current Path associated with the provided path. Using the complete path has the Remaining path value.
func UseLocationHash ¶
UseLocationHash returns the current Path associated with the provided path. Using the hash path has the Remaining path value.
type PushEventHandler ¶
type PushEventHandler struct {
// contains filtered or unexported fields
}
PushEventHandler defines a structure type which implements the PushEventSubscriber interface and the EventDistributor interface.
func NewPushEventHandler ¶
func NewPushEventHandler(fn func(PushEvent)) *PushEventHandler
NewPushEventHandler returns a new instance of a PushEventHandler.
func (*PushEventHandler) Handle ¶
func (sn *PushEventHandler) Handle(receive interface{})
Handle takes the giving value and asserts the expected value to match the PushEvent type then passes it to the Receive method.
func (*PushEventHandler) Receive ¶
func (sn *PushEventHandler) Receive(elem PushEvent)
Receive takes the giving value and execute it against the underline handler.
type PushEventNotification ¶
type PushEventNotification struct {
// contains filtered or unexported fields
}
PushEventNotification defines a structure type which must be used to receive PushEvent type has a event.
func NewPushEventNotification ¶
func NewPushEventNotification() *PushEventNotification
NewPushEventNotification returns a new instance of NewPushEventNotification.
func NewPushEventNotificationWith ¶
func NewPushEventNotificationWith(validation func(PushEvent) bool) *PushEventNotification
NewPushEventNotificationWith returns a new instance of PushEventNotification.
func (*PushEventNotification) Handle ¶
func (sn *PushEventNotification) Handle(elem interface{})
Handle takes the giving value and asserts the expected value to be of the type and pass on to it's underline subscribers else ignoring the event.
func (*PushEventNotification) Notify ¶
func (sn *PushEventNotification) Notify(sub PushEventSubscriber)
Notify adds the given subscriber into the notification list and will await an update of a new event of the given PushEvent type.
func (*PushEventNotification) UnNotify ¶
func (sn *PushEventNotification) UnNotify(sub PushEventSubscriber)
UnNotify removes the given subscriber from the notification's list if found from future events.
type PushEventSubscriber ¶
type PushEventSubscriber interface {
Receive(PushEvent)
}
PushEventSubscriber defines a interface that which is used to subscribe specifically for events PushEvent type.
type Resolvable ¶
type Resolvable interface {
Resolve(PushEvent)
}
Resolvable defines an interface for a resolvable type object.
type ResolveMorpher ¶
ResolveMorpher defines an interface for a Resolver which can morph a trees.Markup state.
type Resolver ¶
type Resolver interface { Resolvable Flush() Pattern() string Only(string, ...trees.SwitchMorpher) ResolveMorpher Register(Resolver) Done(Handler) Resolver Failed(Handler) Resolver Test(string) (map[string]string, string, bool) }
Resolver defines an interface for a type that resolves a provided instance of a dispatch.PushEvent.
func ListenAndResolve ¶
ListenAndResolve takes the giving pattern, matches it against changes provided by the current PathObserver, if the full URL(i.e Path+Hash) matches then fires the provided function.
func NewResolver ¶
NewResolver returns a new instance of a structure that matches the Resolver interface.
type RouteApplier ¶
type RouteApplier interface { Resolver trees.Morpher trees.Appliable Root() RouteApplier N(string) RouteApplier Next(string, trees.SwitchMorpher) RouteApplier }
RouteApplier defines a interface which composes trees Applier, Morpher and the Resolver to handle routing over against a tree markup.
type RouteManager ¶
type RouteManager struct {
Levels map[string]RouteApplier
}
RouteManager defines a router which handles creation and registering of a set of level connecting routes
func NewRouteManager ¶
func NewRouteManager() *RouteManager
NewRouteManager returns a new instance of RouteManager.
func (*RouteManager) L ¶
func (r *RouteManager) L(path string) RouteApplier
L returns a RouteApplier attached to a giving manager which cache and manages the different defined routes.
func (*RouteManager) Level ¶
func (r *RouteManager) Level(path string, morpher trees.SwitchMorpher) RouteApplier
Level creates a new route level using the provided string as the base path for its root router.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router exposes a struct which describes a multi-handler of request where it
func (*Router) Delete ¶
Delete retrieves the giving path and returns the response expected using a DELETE method.
func (*Router) Do ¶
func (r *Router) Do(method string, path string, params Params, body io.ReadCloser) (*http.Response, error)
Do performs the giving requests for a giving path with the provided body and returns the response for that method.
func (*Router) Get ¶
Get retrieves the giving path and returns the response expected using a GET method.
func (*Router) Head ¶
Head retrieves the giving path and returns the response expected using a HEAD method.
func (*Router) Options ¶
Options retrieves the giving path and returns the response expected using a OPTIONS method.
func (*Router) Patch ¶
Patch retrieves the giving path and returns the response expected using a PATCH method.
type Routing ¶
type Routing struct { Resolver // contains filtered or unexported fields }
Routing defines a Resolve structure that allows morphing the output of a markup based on a giving route.
func NewRouting ¶
func NewRouting(path string, morpher trees.SwitchMorpher) *Routing
NewRouting returns a new instance of a Routing struct.