Documentation ¶
Overview ¶
Package web exposes the extension points of the Service Manager. One can add additional controllers, filters and plugins to already built SM.
Index ¶
- Constants
- func ContextWithAuthorization(ctx context.Context) context.Context
- func ContextWithUser(ctx context.Context, user *UserContext) context.Context
- func IsAuthorized(ctx context.Context) bool
- type API
- func (api *API) RegisterControllers(controllers ...Controller)
- func (api *API) RegisterFilters(filters ...Filter)
- func (api *API) RegisterFiltersAfter(afterFilterName string, filters ...Filter)
- func (api *API) RegisterFiltersBefore(beforeFilterName string, filters ...Filter)
- func (api *API) RegisterPlugins(plugins ...Plugin)
- func (api *API) RemoveFilter(name string)
- func (api *API) ReplaceFilter(replacedFilterName string, filter Filter)
- type Binder
- type BindingFetcher
- type BindingPoller
- type CatalogFetcher
- type Controller
- type CredentialsAdapter
- type Data
- type Deprovisioner
- type Endpoint
- type Filter
- type FilterMatcher
- type Filters
- type Handler
- type HandlerFunc
- type InstancePoller
- type Matcher
- type MatcherFunc
- type Middleware
- type MiddlewareFunc
- type Named
- type Plugin
- type Provisioner
- type Request
- type Response
- type Route
- type ServiceFetcher
- type ServiceUpdater
- type Unbinder
- type UserContext
Constants ¶
const ( // BrokersURL is the URL path to manage service brokers BrokersURL = "/" + apiVersion + "/service_brokers" // ServiceOfferingsURL is the URL path to manage service offerings ServiceOfferingsURL = "/" + apiVersion + "/service_offerings" // ServicePlansURL is the URL path to manage service plans ServicePlansURL = "/" + apiVersion + "/service_plans" // VisibilitiesURL is the URL path to manage visibilities VisibilitiesURL = "/" + apiVersion + "/visibilities" // PlatformsURL is the URL path to manage platforms PlatformsURL = "/" + apiVersion + "/platforms" // OSBURL is the OSB API base URL path OSBURL = "/" + apiVersion + "/osb" // MonitorHealthURL is the path of the healthcheck endpoint MonitorHealthURL = "/" + apiVersion + "/monitor/health" // InfoURL is the path of the info endpoint InfoURL = "/" + apiVersion + "/info" )
Variables ¶
This section is empty.
Functions ¶
func ContextWithAuthorization ¶ added in v0.1.1
ContextWithAuthorization sets the boolean flag isAuthorized in the request context
func ContextWithUser ¶ added in v0.1.1
func ContextWithUser(ctx context.Context, user *UserContext) context.Context
ContextWithUser sets the authenticated user in the context
func IsAuthorized ¶ added in v0.1.1
IsAuthorized returns whether the request has been authorized
Types ¶
type API ¶
type API struct { // Controllers contains the registered controllers Controllers []Controller // Filters contains the registered filters Filters []Filter // Registry is the health indicators registry for this API health.Registry }
API is the primary point for REST API registration
func (*API) RegisterControllers ¶
func (api *API) RegisterControllers(controllers ...Controller)
RegisterControllers registers a set of controllers
func (*API) RegisterFilters ¶
RegisterFilters registers a set of filters
func (*API) RegisterFiltersAfter ¶
RegisterFiltersAfter registers the specified filter after the one with the given name. If for some routes, the filter with the given name does not match the routes of the provided filter, then the filter will be registered after the place at which the filter with this name would have been, had it been configured to match route.
func (*API) RegisterFiltersBefore ¶
RegisterFiltersBefore registers the specified filters before the one with the given name. If for some routes, the filter with the given name does not match the routes of the provided filter, then the filters will be registered at the place at which the filter with this name would have been, had it been configured to match route.
func (*API) RegisterPlugins ¶
RegisterPlugins registers a set of plugins
func (*API) RemoveFilter ¶
RemoveFilter removes the filter with the given name
func (*API) ReplaceFilter ¶
ReplaceFilter registers the given filter in the place of the filter with the given name.
type Binder ¶
Binder should be implemented by plugins that need to intercept OSB call for bind service operation
type BindingFetcher ¶
type BindingFetcher interface { Plugin FetchBinding(request *Request, next Handler) (*Response, error) }
BindingFetcher should be implemented by plugins that need to intercept OSB call for unbind service operation
type BindingPoller ¶
type BindingPoller interface { Plugin PollBinding(request *Request, next Handler) (*Response, error) }
BindingPoller should be implemented by plugins that need to intercept OSB Calls for polling last operation for service bindings
type CatalogFetcher ¶
type CatalogFetcher interface { Plugin FetchCatalog(request *Request, next Handler) (*Response, error) }
CatalogFetcher should be implemented by plugins that need to intercept OSB call for get catalog operation
type Controller ¶
type Controller interface { // Routes returns the set of routes for this controller Routes() []Route }
Controller is an entity that wraps a set of HTTP Routes
type CredentialsAdapter ¶ added in v0.1.5
type Data ¶ added in v0.1.6
type Data interface { // Data reads the additional data from the context into the specified struct Data(v interface{}) error }
type Deprovisioner ¶
type Deprovisioner interface { Plugin Deprovision(request *Request, next Handler) (*Response, error) }
Deprovisioner should be implemented by plugins that need to intercept OSB call for deprovision operation
type Filter ¶
type Filter interface { Named Middleware // FilterMatchers Returns a set of FilterMatchers each containing a set of Matchers. Each FilterMatcher represents // one place where the Filter would run. FilterMatchers() []FilterMatcher }
Filter is an interface that Named Middlewares that should satisfy a set of Matchers (conditions) should implement.
type FilterMatcher ¶
type FilterMatcher struct { // Matchers represents a set of conditions that need to be matched Matchers []Matcher }
FilterMatcher type represents a set of conditions (Matchers) that need to match if order for a FilterMatcher to match
type Filters ¶
type Filters []Filter
Filters represents a slice of Filter elements
func (Filters) Chain ¶
Chain chains the Filters around the specified Handler and returns a Handler. It also adds logic for logging before entering and after exiting from filters.
func (Filters) ChainMatching ¶
ChainMatching builds a pkg/web.Handler that chains up the filters that match the provided route and the actual handler
type Handler ¶
type Handler interface { // Handle processes a Request and returns a corresponding Response or error Handle(req *Request) (resp *Response, err error) }
Handler is an interface that objects can implement to be registered in the SM REST API.
type HandlerFunc ¶
HandlerFunc is an adapter that allows to use regular functions as Handler interface implementations.
type InstancePoller ¶
type InstancePoller interface { Plugin PollInstance(request *Request, next Handler) (*Response, error) }
InstancePoller should be implemented by plugins that need to intercept OSB calls for polling last operation for service instances
type Matcher ¶
type Matcher interface { // Matches matches a route against a particular condition Matches(endpoint Endpoint) (bool, error) }
Matcher allows checking whether an Endpoint matches a particular condition
type MatcherFunc ¶
MatcherFunc is an adapter that allows regular functions to act as Matchers
type Middleware ¶
type Middleware interface { // Run returns a handler that contains the handling logic of the Middleware. The implementation of Run // should invoke next's Handle if the request should be chained to the next Handler. // It may also terminate the request by not invoking the next Handler. Run(req *Request, next Handler) (*Response, error) }
Middleware is an interface that objects that should act as filters or plugins need to implement. It intercepts the request before reaching the final handler and allows during preprocessing and postprocessing.
type MiddlewareFunc ¶
MiddlewareFunc is an adapter that allows to use regular functions as Middleware
type Named ¶
type Named interface { // Name returns the string identifier for the object Name() string }
Named is an interface that objects that need to be identified by a particular name should implement.
type Plugin ¶
type Plugin interface { Named }
Plugin can intercept Service Manager operations and augment them with additional logic. To intercept SM operations a plugin implements one or more of the interfaces defined in this package.
type Provisioner ¶
Provisioner should be implemented by plugins that need to intercept OSB call for provision operation
type Request ¶
type Request struct { // Request is the original http.Request *http.Request // PathParams contains the URL path parameters PathParams map[string]string // Body is the loaded request body (usually JSON) Body []byte }
Request contains the original http.Request, path parameters and the raw body Request.Request.Body should not be used as it would be already processed by internal implementation
type Response ¶
type Response struct { // StatusCode is the HTTP status code StatusCode int // Header contains the response headers Header http.Header // Body is the response body (usually JSON) Body []byte }
Response defines the attributes of the HTTP response that will be sent to the client
type Route ¶
type Route struct { // Endpoint is the combination of Path and HTTP Method for the specified route Endpoint Endpoint // Handler is the function that should handle incoming requests for this endpoint Handler HandlerFunc }
Route is a mapping between an Endpoint and a REST API SMHandler
type ServiceFetcher ¶
type ServiceFetcher interface { Plugin FetchService(request *Request, next Handler) (*Response, error) }
ServiceFetcher should be implemented by plugins that need to intercept OSB call for get service operation
type ServiceUpdater ¶
type ServiceUpdater interface { Plugin UpdateService(request *Request, next Handler) (*Response, error) }
ServiceUpdater should be implemented by plugins that need to intercept OSB call for update service operation
type Unbinder ¶
Unbinder should be implemented by plugins that need to intercept OSB call for unbind service operation
type UserContext ¶ added in v0.1.6
UserContext holds the information for the current user
func UserFromContext ¶
func UserFromContext(ctx context.Context) (*UserContext, bool)
UserFromContext gets the authenticated user from the context