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") )
Keys for extensions to get things out of the context
Functions ¶
func NewDatastore ¶
func NewDatastore(ds models.Datastore, al AppListener, fl FnListener, tl TriggerListener) models.Datastore
NewDatastore returns a Datastore that wraps the provided Datastore, calling any relevant listeners around any of the Datastore methods.
Types ¶
type APIHandler ¶
type APIHandler interface {
ServeHTTP(w http.ResponseWriter, r *http.Request)
}
APIHandler may be used to add an http endpoint on the versioned route of the Fn API.
type APIHandlerFunc ¶
type APIHandlerFunc func(w http.ResponseWriter, r *http.Request)
APIHandlerFunc is a convenience to make an APIHandler.
func (APIHandlerFunc) ServeHTTP ¶
func (f APIHandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP calls f(w, r).
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, appID 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 the 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 adds a listener that will be invoked around any relevant methods. AddAppListener(listener AppListener) // AddCallListener adds a listener that will be invoked around any call invocations. 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 /v2/x AddEndpoint(method, path string, handler APIHandler) // AddEndpoint adds an endpoint to /v2/x AddEndpointFunc(method, path string, handler func(w http.ResponseWriter, r *http.Request)) // Datastore returns the Datastore Fn is using Datastore() models.Datastore }
ExtServer limits what the extension should do and prevents dependency loop, it can be used to alter / modify / add the behavior of fn server.
type Extension ¶
Extension is the interface that all extensions must implement in order to configure themselves against an ExtServer.
type FnListener ¶
type FnListener interface { // BeforeFnCreate called before fn created in the datastore BeforeFnCreate(ctx context.Context, fn *models.Fn) error // AfterFnCreate called after fn create in the datastore AfterFnCreate(ctx context.Context, fn *models.Fn) error // BeforeFnUpdate called before fn update in datastore BeforeFnUpdate(ctx context.Context, fn *models.Fn) error // AfterFnUpdate called after fn updated in datastore AfterFnUpdate(ctx context.Context, fn *models.Fn) error // BeforeFnDelete called before fn deleted from the datastore BeforeFnDelete(ctx context.Context, fnID string) error // AfterFnDelete called after fn deleted from the datastore AfterFnDelete(ctx context.Context, fnID string) error }
FnListener enables callbacks around Fn events
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 MiddlewareFunc ¶
MiddlewareFunc is a here to allow a plain function to be a middleware.
type TriggerListener ¶
type TriggerListener interface { // BeforeTriggerCreate called before trigger created in the datastore BeforeTriggerCreate(ctx context.Context, trigger *models.Trigger) error // AfterTriggerCreate called after trigger create in the datastore AfterTriggerCreate(ctx context.Context, trigger *models.Trigger) error // BeforeTriggerUpdate called before trigger update in datastore BeforeTriggerUpdate(ctx context.Context, trigger *models.Trigger) error // AfterTriggerUpdate called after trigger updated in datastore AfterTriggerUpdate(ctx context.Context, trigger *models.Trigger) error // BeforeTriggerDelete called before trigger deleted from the datastore BeforeTriggerDelete(ctx context.Context, triggerId string) error // AfterTriggerDelete called after trigger deleted from the datastore AfterTriggerDelete(ctx context.Context, triggerId string) error }
TriggerListener enables callbacks around Trigger events