Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // MiddlewareControllerKey is a context key. It can be used in handlers with context.WithValue to // access the MiddlewareContext. MiddlewareControllerKey = contextKey("middleware_controller") // AppNameKey AppNameKey = contextKey("app_name") )
Keys for extensions to get things out of the context
Functions ¶
This section is empty.
Types ¶
type ApiAppHandler ¶
type ApiAppHandlerFunc ¶
func (ApiAppHandlerFunc) ServeHTTP ¶
func (f ApiAppHandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request, app *models.App)
ServeHTTP calls f(w, r).
type ApiHandler ¶
type ApiHandler interface { // Handle(ctx context.Context) ServeHTTP(w http.ResponseWriter, r *http.Request) }
type ApiHandlerFunc ¶
type ApiHandlerFunc func(w http.ResponseWriter, r *http.Request)
func (ApiHandlerFunc) ServeHTTP ¶
func (f ApiHandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP calls f(w, r).
type ApiRouteHandler ¶
type ApiRouteHandlerFunc ¶
type AppListener ¶
type AppListener interface { // BeforeAppCreate called right before creating App in the database BeforeAppCreate(ctx context.Context, app *models.App) error // AfterAppCreate called after creating App in the database AfterAppCreate(ctx context.Context, app *models.App) error // BeforeAppUpdate called right before updating App in the database BeforeAppUpdate(ctx context.Context, app *models.App) error // AfterAppUpdate called after updating App in the database AfterAppUpdate(ctx context.Context, app *models.App) error // BeforeAppDelete called right before deleting App in the database BeforeAppDelete(ctx context.Context, app *models.App) error // AfterAppDelete called after deleting App in the database AfterAppDelete(ctx context.Context, app *models.App) error // BeforeAppGet called right before getting an app BeforeAppGet(ctx context.Context, appName string) error // AfterAppGet called after getting app from database AfterAppGet(ctx context.Context, app *models.App) error // BeforeAppsList called right before getting a list of all user's apps. Modify the filter to adjust what gets returned. BeforeAppsList(ctx context.Context, filter *models.AppFilter) error // AfterAppsList called after deleting getting a list of user's apps. apps is the result after applying AppFilter. AfterAppsList(ctx context.Context, apps []*models.App) error }
AppListener is an interface used to inject custom code at key points in app lifecycle.
type CallListener ¶
type CallListener interface { // BeforeCall called before a function is executed BeforeCall(ctx context.Context, call *models.Call) error // AfterCall called after a function completes AfterCall(ctx context.Context, call *models.Call) error }
CallListener enables callbacks around Call events
type ExtServer ¶
type ExtServer interface { AddAppListener(listener AppListener) AddCallListener(listener CallListener) // AddAPIMiddleware add middleware AddAPIMiddleware(m Middleware) // AddAPIMiddlewareFunc add middlewarefunc AddAPIMiddlewareFunc(m MiddlewareFunc) // AddRootMiddleware add middleware add middleware for end user applications AddRootMiddleware(m Middleware) // AddRootMiddlewareFunc add middleware for end user applications AddRootMiddlewareFunc(m MiddlewareFunc) // AddEndpoint adds an endpoint to /v1/x AddEndpoint(method, path string, handler ApiHandler) // AddEndpoint adds an endpoint to /v1/x AddEndpointFunc(method, path string, handler func(w http.ResponseWriter, r *http.Request)) // AddAppEndpoint adds an endpoints to /v1/apps/:app/x AddAppEndpoint(method, path string, handler ApiAppHandler) // AddAppEndpoint adds an endpoints to /v1/apps/:app/x AddAppEndpointFunc(method, path string, handler func(w http.ResponseWriter, r *http.Request, app *models.App)) // AddRouteEndpoint adds an endpoints to /v1/apps/:app/routes/:route/x AddRouteEndpoint(method, path string, handler ApiRouteHandler) // AddRouteEndpoint adds an endpoints to /v1/apps/:app/routes/:route/x AddRouteEndpointFunc(method, path string, handler func(w http.ResponseWriter, r *http.Request, app *models.App, route *models.Route)) // Datastore returns the Datastore Fn is using Datastore() models.Datastore }
NOTE: ExtServer limits what the extension should do and prevents dependency loop
type Middleware ¶
Middleware just takes a http.Handler and returns one. So the next middle ware must be called within the returned handler or it would be ignored.
type MiddlewareController ¶
type MiddlewareController interface { // CallFunction skips any API routing and goes down the function path CallFunction(w http.ResponseWriter, r *http.Request) // If function has already been called FunctionCalled() bool }
MiddlewareController allows a bit more flow control to the middleware, since we multiple paths a request can go down. 1) Could be routed towards the API 2) Could be routed towards a function
func GetMiddlewareController ¶
func GetMiddlewareController(ctx context.Context) MiddlewareController
GetMiddlewareController returns MiddlewareController from context.