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 AuthenticationErrorFromContext(ctx context.Context) (bool, error)
- func AuthorizationErrorFromContext(ctx context.Context) (bool, error)
- func ContextWithAuthenticationError(ctx context.Context, authNError error) context.Context
- func ContextWithAuthorization(ctx context.Context) context.Context
- func ContextWithAuthorizationError(ctx context.Context, authZError error) context.Context
- func ContextWithUser(ctx context.Context, user *UserContext) context.Context
- func IsAuthorized(ctx context.Context) bool
- func Matching(filterMatchers []FilterMatcher, endpoint Endpoint) (bool, error)
- 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) RegisterPluginsBefore(beforePluginName string, plugins ...Plugin)
- func (api *API) RemoveFilter(name string)
- func (api *API) ReplaceFilter(replacedFilterName string, filter Filter)
- type AccessLevel
- type AuthenticationType
- type Binder
- type BindingFetcher
- type BindingPoller
- type CatalogFetcher
- type Controller
- type CredentialsAdapter
- type Deprovisioner
- type DynamicMatchingFilter
- 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 ( // ServiceBrokersURL is the URL path to manage service brokers ServiceBrokersURL = "/" + 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" // ServiceInstancesURL is the URL path to manage service instances ServiceInstancesURL = "/" + apiVersion + "/service_instances" // VisibilitiesURL is the URL path to manage visibilities VisibilitiesURL = "/" + apiVersion + "/visibilities" // NotificationsURL is the URL path to manage notifications NotificationsURL = "/" + apiVersion + "/notifications" // 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" // ConfigURL is the Configuration API base URL path ConfigURL = "/" + apiVersion + "/config" // LoggingConfigURL is the Logging Configuration API URL path LoggingConfigURL = ConfigURL + "/logging" // OperationsURL is the URL path fetch operations OperationsURL = "/operations" )
Variables ¶
This section is empty.
Functions ¶
func AuthenticationErrorFromContext ¶ added in v0.9.7
func AuthorizationErrorFromContext ¶ added in v0.9.7
func ContextWithAuthenticationError ¶ added in v0.9.7
func ContextWithAuthorization ¶ added in v0.1.1
ContextWithAuthorization sets the boolean flag isAuthorized in the request context
func ContextWithAuthorizationError ¶ added in v0.9.7
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) RegisterPluginsBefore ¶ added in v0.9.1
RegisterPluginsBefore registers a set of plugins before the plugin with the specified name
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 AccessLevel ¶ added in v0.7.0
type AccessLevel int
AccessLevel specifies the access level privileges that are stored in the user context
const ( //NoAccess is the default value for access level - it is used when no explicit access was granted NoAccess AccessLevel = iota // TenantAccess means access was granted to manage the tenant's own resources. Such access might be granted to a user // so that he can manage his own data TenantAccess // AllTenantAccess means access was granted to manage the resources of all tenants. Such access might be granted // to systems that have to manage data across multiple tenants AllTenantAccess // GlobalAccess means access was granted to manage global resources (such resources are not scoped or associated with tenant. // Such access might be granted to systems that need to manage global resources GlobalAccess )
func (AccessLevel) String ¶ added in v0.7.0
func (a AccessLevel) String() string
String implements Stringer and converts the decision to human-readable value
type AuthenticationType ¶ added in v0.4.1
type AuthenticationType int
AuthenticationType specifies the authentication type that is stored in the user context
const ( Basic AuthenticationType = iota Bearer )
func (AuthenticationType) String ¶ added in v0.7.0
func (a AuthenticationType) String() string
String implements Stringer and converts the decision to human-readable value
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 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 DynamicMatchingFilter ¶ added in v0.9.7
type DynamicMatchingFilter struct {
// contains filtered or unexported fields
}
func NewDynamicMatchingFilter ¶ added in v0.9.7
func NewDynamicMatchingFilter(name string) *DynamicMatchingFilter
func (*DynamicMatchingFilter) AddFilter ¶ added in v0.9.7
func (dmf *DynamicMatchingFilter) AddFilter(dynamicFilter Filter)
func (*DynamicMatchingFilter) FilterMatchers ¶ added in v0.9.7
func (dmf *DynamicMatchingFilter) FilterMatchers() []FilterMatcher
func (*DynamicMatchingFilter) Name ¶ added in v0.9.7
func (dmf *DynamicMatchingFilter) Name() string
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
func Methods ¶
Methods returns a Matcher that matches to routes that contain any of the specified methods
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 // contains filtered or unexported fields }
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
func (*Request) HijackResponseWriter ¶ added in v0.3.0
func (r *Request) HijackResponseWriter() http.ResponseWriter
func (*Request) IsResponseWriterHijacked ¶ added in v0.3.0
func (*Request) SetResponseWriter ¶ added in v0.3.0
func (r *Request) SetResponseWriter(rw http.ResponseWriter)
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
type UserContext struct { // Data unmarshals the additional user context details into the specified struct Data func(data interface{}) error // AuthenticationType is the authentication type for this user context AuthenticationType AuthenticationType // Name is the name of the authenticated user Name string // AccessLevel is the user access level AccessLevel AccessLevel }
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