Documentation ¶
Overview ¶
Package server provides methods for parts of the server where a listener will bind to a host and port to provide services to external systems/users.
Index ¶
- type HTTPListenerService
- func (service *HTTPListenerService) AddMiddleware(middlewareHandler alice.Constructor) *HTTPListenerService
- func (service *HTTPListenerService) AddRoute(path string, handlerFunc http.HandlerFunc, methods ...string) *HTTPListenerService
- func (service *HTTPListenerService) AddRouteWithMiddleware(path string, handlerFunc http.HandlerFunc, middlewareHandler alice.Constructor, ...) *HTTPListenerService
- func (service *HTTPListenerService) AddStaticRoute(pathPrefix string, directory string) *HTTPListenerService
- func (service *HTTPListenerService) StartHTTPListener() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPListenerService ¶
type HTTPListenerService struct { Address string Port int Context *middleware.AppContext Router *mux.Router BaseMiddlewareHandlers alice.Chain }
HTTPListenerService is a structure which provides an HTTP listener to service requests. This structure offers methods to add routes and middlewares. Typical usage would first call NewHTTPListenerService(), add routes, then call StartHTTPListener.
func NewHTTPListenerService ¶
func NewHTTPListenerService( address string, port int, appContext *middleware.AppContext, ) *HTTPListenerService
NewHTTPListenerService creates a new instance of the HTTPListenerService
func (*HTTPListenerService) AddMiddleware ¶
func (service *HTTPListenerService) AddMiddleware(middlewareHandler alice.Constructor) *HTTPListenerService
AddMiddleware adds a new middleware handler to the request chain.
func (*HTTPListenerService) AddRoute ¶
func (service *HTTPListenerService) AddRoute( path string, handlerFunc http.HandlerFunc, methods ...string, ) *HTTPListenerService
AddRoute adds a HTTP handler route to the HTTP listener.
func (*HTTPListenerService) AddRouteWithMiddleware ¶
func (service *HTTPListenerService) AddRouteWithMiddleware( path string, handlerFunc http.HandlerFunc, middlewareHandler alice.Constructor, methods ...string, ) *HTTPListenerService
AddRouteWithMiddleware adds a HTTP handler route that goes through an additional middleware handler, to the HTTP listener.
func (*HTTPListenerService) AddStaticRoute ¶
func (service *HTTPListenerService) AddStaticRoute(pathPrefix string, directory string) *HTTPListenerService
AddStaticRoute adds a HTTP handler route for static assets.
func (*HTTPListenerService) StartHTTPListener ¶
func (service *HTTPListenerService) StartHTTPListener() error
StartHTTPListener starts the HTTP listener and servicing requests.