routers

package
v5.10.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2019 License: MIT, MIT, MIT, + 1 more Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Lister listerFunc

Lister represents the active Lister function

Functions

func HTTPStatusFromCode

func HTTPStatusFromCode(code actions.ErrCode) int

HTTPStatusFromCode returns http status code for given user action err code

func List

func List(list ListControllerFunc, fields FieldsFunc) http.HandlerFunc

List handles resources listing with pagination support

func RespondWith

func RespondWith(w http.ResponseWriter, resources interface{})

RespondWith given writer and resource, marshal to JSON and write response.

func UnmarshalBody

func UnmarshalBody(req *http.Request, record interface{}) error

UnmarshalBody decodes the request body

func WriteError

func WriteError(w http.ResponseWriter, err error)

WriteError writes error response in JSON format.

Types

type AssetsRouter

type AssetsRouter struct {
	// contains filtered or unexported fields
}

AssetsRouter handles requests for /assets

func NewAssetRouter

func NewAssetRouter(store store.ResourceStore) *AssetsRouter

NewAssetRouter instantiates new router for controlling asset resources

func (*AssetsRouter) Mount

func (r *AssetsRouter) Mount(parent *mux.Router)

Mount the AssetsRouter to a parent Router

type AuthenticationRouter

type AuthenticationRouter struct {
	// contains filtered or unexported fields
}

AuthenticationRouter handles authentication related requests

func NewAuthenticationRouter

func NewAuthenticationRouter(store store.Store, authenticator *authentication.Authenticator) *AuthenticationRouter

NewAuthenticationRouter instantiates new router.

func (*AuthenticationRouter) Mount

func (a *AuthenticationRouter) Mount(r *mux.Router)

Mount the authentication routes on given mux.Router.

type ChecksRouter

type ChecksRouter struct {
	// contains filtered or unexported fields
}

ChecksRouter handles requests for /checks

func NewChecksRouter

func NewChecksRouter(store store.Store, getter types.QueueGetter) *ChecksRouter

NewChecksRouter instantiates new router for controlling check resources

func (*ChecksRouter) Mount

func (r *ChecksRouter) Mount(parent *mux.Router)

Mount the ChecksRouter to a parent Router

type ClusterController

type ClusterController interface {
	// MemberList lists the current cluster membership.
	MemberList(ctx context.Context) (*clientv3.MemberListResponse, error)

	// MemberAdd adds a new member into the cluster.
	MemberAdd(ctx context.Context, peerAddrs []string) (*clientv3.MemberAddResponse, error)

	// MemberRemove removes an existing member from the cluster.
	MemberRemove(ctx context.Context, id uint64) (*clientv3.MemberRemoveResponse, error)

	// MemberUpdate updates the peer addresses of the member.
	MemberUpdate(ctx context.Context, id uint64, peerAddrs []string) (*clientv3.MemberUpdateResponse, error)

	// ClusterID gets the sensu cluster id.
	ClusterID(ctx context.Context) (string, error)
}

ClusterController represents the controller needs of the ClusterRouter.

type ClusterRoleBindingsRouter

type ClusterRoleBindingsRouter struct {
	// contains filtered or unexported fields
}

ClusterRoleBindingsRouter handles requests for ClusterRoleBindings.

func NewClusterRoleBindingsRouter

func NewClusterRoleBindingsRouter(store store.ResourceStore) *ClusterRoleBindingsRouter

NewClusterRoleBindingsRouter instantiates a new router for ClusterRoleBindings.

func (*ClusterRoleBindingsRouter) Mount

func (r *ClusterRoleBindingsRouter) Mount(parent *mux.Router)

Mount the ClusterRoleBindingsRouter on the given parent Router

type ClusterRolesRouter

type ClusterRolesRouter struct {
	// contains filtered or unexported fields
}

ClusterRolesRouter handles requests for ClusterRoles.

func NewClusterRolesRouter

func NewClusterRolesRouter(store store.ResourceStore) *ClusterRolesRouter

NewClusterRolesRouter instantiates a new router for ClusterRoles.

func (*ClusterRolesRouter) Mount

func (r *ClusterRolesRouter) Mount(parent *mux.Router)

Mount the ClusterRolesRouter on the given parent Router

type ClusterRouter

type ClusterRouter struct {
	// contains filtered or unexported fields
}

ClusterRouter handles requests for /cluster

func NewClusterRouter

func NewClusterRouter(ctrl ClusterController) *ClusterRouter

NewClusterRouter creates a new ClusterRouter.

func (*ClusterRouter) Mount

func (r *ClusterRouter) Mount(parent *mux.Router)

Mount mounts the ClusterRouter to a parent Router.

type EntitiesRouter

type EntitiesRouter struct {
	// contains filtered or unexported fields
}

EntitiesRouter handles requests for /entities

func NewEntitiesRouter

func NewEntitiesRouter(store store.Store, events store.EventStore) *EntitiesRouter

NewEntitiesRouter instantiates new router for controlling entities resources

func (*EntitiesRouter) Mount

func (r *EntitiesRouter) Mount(parent *mux.Router)

Mount the EntitiesRouter to a parent Router

type EventFiltersRouter

type EventFiltersRouter struct {
	// contains filtered or unexported fields
}

EventFiltersRouter handles /filters requests.

func NewEventFiltersRouter

func NewEventFiltersRouter(store store.ResourceStore) *EventFiltersRouter

NewEventFiltersRouter creates a new EventFiltersRouter.

func (*EventFiltersRouter) Mount

func (r *EventFiltersRouter) Mount(parent *mux.Router)

Mount the EventFiltersRouter to a parent Router

type EventsRouter

type EventsRouter struct {
	// contains filtered or unexported fields
}

EventsRouter handles requests for /events

func NewEventsRouter

func NewEventsRouter(store store.EventStore, bus messaging.MessageBus) *EventsRouter

NewEventsRouter instantiates new events controller

func (*EventsRouter) Mount

func (r *EventsRouter) Mount(parent *mux.Router)

Mount the EventsRouter to a parent Router

type ExtensionsRouter

type ExtensionsRouter struct {
	// contains filtered or unexported fields
}

ExtensionsRouter handles requests for /extensions

func NewExtensionsRouter

func NewExtensionsRouter(store store.ResourceStore) *ExtensionsRouter

NewExtensionsRouter creates a new router for controlling extension resources

func (*ExtensionsRouter) Mount

func (r *ExtensionsRouter) Mount(parent *mux.Router)

Mount the ExtensionsRouter to a parent Router

type FieldsFunc

type FieldsFunc func(resource corev2.Resource) map[string]string

FieldsFunc represents the function to retrieve fields about a given resource

type GraphQLRouter

type GraphQLRouter struct {
	// contains filtered or unexported fields
}

GraphQLRouter handles requests for /events

func NewGraphQLRouter

func NewGraphQLRouter(apiURL string, tls *tls.Config, store store.Store) *GraphQLRouter

NewGraphQLRouter instantiates new events controller

func (*GraphQLRouter) Mount

func (r *GraphQLRouter) Mount(parent *mux.Router)

Mount the GraphQLRouter to a parent Router

type HandlersRouter

type HandlersRouter struct {
	// contains filtered or unexported fields
}

HandlersRouter handles requests for /handlers

func NewHandlersRouter

func NewHandlersRouter(store store.ResourceStore) *HandlersRouter

NewHandlersRouter instantiates new router for controlling handler resources

func (*HandlersRouter) Mount

func (r *HandlersRouter) Mount(parent *mux.Router)

Mount the HandlersRouter to a parent Router

type HealthController

type HealthController interface {
	GetClusterHealth(ctx context.Context) *types.HealthResponse
}

HealthController represents the controller needs of the HealthRouter

type HealthRouter

type HealthRouter struct {
	// contains filtered or unexported fields
}

HealthRouter handles requests for /health

func NewHealthRouter

func NewHealthRouter(ctrl HealthController) *HealthRouter

NewHealthRouter instantiates new router for controlling health info

func (*HealthRouter) Mount

func (r *HealthRouter) Mount(parent *mux.Router)

Mount the HealthRouter to a parent Router

type HooksRouter

type HooksRouter struct {
	// contains filtered or unexported fields
}

HooksRouter handles requests for /hooks

func NewHooksRouter

func NewHooksRouter(store store.ResourceStore) *HooksRouter

NewHooksRouter instantiates new router for controlling hook resources

func (*HooksRouter) Mount

func (r *HooksRouter) Mount(parent *mux.Router)

Mount the HooksRouter to a parent Router

type ListControllerFunc

type ListControllerFunc func(ctx context.Context, pred *store.SelectionPredicate) ([]corev2.Resource, error)

ListControllerFunc represents a generic controller for listing resources

type MutatorsRouter

type MutatorsRouter struct {
	// contains filtered or unexported fields
}

MutatorsRouter handles /mutators requests.

func NewMutatorsRouter

func NewMutatorsRouter(store store.ResourceStore) *MutatorsRouter

NewMutatorsRouter creates a new MutatorsRouter.

func (*MutatorsRouter) Mount

func (r *MutatorsRouter) Mount(parent *mux.Router)

Mount the MutatorsRouter to a parent Router

type NamespacesRouter

type NamespacesRouter struct {
	// contains filtered or unexported fields
}

NamespacesRouter handles requests for /namespaces

func NewNamespacesRouter

func NewNamespacesRouter(store store.ResourceStore) *NamespacesRouter

NewNamespacesRouter instantiates new router for controlling check resources

func (*NamespacesRouter) Mount

func (r *NamespacesRouter) Mount(parent *mux.Router)

Mount the NamespacesRouter to a parent Router

type ResourceRoute

type ResourceRoute struct {
	Router     *mux.Router
	PathPrefix string
}

ResourceRoute mounts resources in a convetional RESTful manner.

routes := ResourceRoute{PathPrefix: "checks", Router: ...}
routes.Get(myShowAction)     // given action is mounted at GET /checks/:id
routes.List(myIndexAction)   // given action is mounted at GET /checks
routes.Put(myCreateAction)   // given action is mounted at PUT /checks/:id
routes.Patch(myUpdateAction) // given action is mounted at PATCH /checks/:id
routes.Post(myCreateAction)  // given action is mounted at POST /checks
routes.Del(myCreateAction)   // given action is mounted at DELETE /checks/:id
routes.Path("{id}/publish", publishAction).Methods(http.MethodDelete) // when you need something customer

func (*ResourceRoute) Del

func (r *ResourceRoute) Del(fn actionHandlerFunc) *mux.Route

Del deletes

func (*ResourceRoute) Get

func (r *ResourceRoute) Get(fn actionHandlerFunc) *mux.Route

Get reads

func (*ResourceRoute) List

func (r *ResourceRoute) List(fn ListControllerFunc, fields FieldsFunc) *mux.Route

List resources

func (*ResourceRoute) ListAllNamespaces

func (r *ResourceRoute) ListAllNamespaces(fn ListControllerFunc, path string, fields FieldsFunc) *mux.Route

ListAllNamespaces return all resources across all namespaces

func (*ResourceRoute) Path

func (r *ResourceRoute) Path(p string, fn actionHandlerFunc) *mux.Route

Path adds custom path

func (*ResourceRoute) Post

func (r *ResourceRoute) Post(fn actionHandlerFunc) *mux.Route

Post creates

func (*ResourceRoute) Put

func (r *ResourceRoute) Put(fn actionHandlerFunc) *mux.Route

Put updates/replaces

type RoleBindingsRouter

type RoleBindingsRouter struct {
	// contains filtered or unexported fields
}

RoleBindingsRouter handles requests for RoleBindings.

func NewRoleBindingsRouter

func NewRoleBindingsRouter(store store.ResourceStore) *RoleBindingsRouter

NewRoleBindingsRouter instantiates a new router for RoleBindings.

func (*RoleBindingsRouter) Mount

func (r *RoleBindingsRouter) Mount(parent *mux.Router)

Mount the RoleBindingsRouter on the given parent Router

type RolesRouter

type RolesRouter struct {
	// contains filtered or unexported fields
}

RolesRouter handles requests for Roles.

func NewRolesRouter

func NewRolesRouter(store store.ResourceStore) *RolesRouter

NewRolesRouter instantiates a new router for Roles.

func (*RolesRouter) Mount

func (r *RolesRouter) Mount(parent *mux.Router)

Mount the RolesRouter on the given parent Router

type Router

type Router interface {
	Mount(*mux.Router)
}

Router mounts new subrouters on parent routers

type SilencedRouter

type SilencedRouter struct {
	// contains filtered or unexported fields
}

SilencedRouter handles requests for /users

func NewSilencedRouter

func NewSilencedRouter(store store.Store) *SilencedRouter

NewSilencedRouter instantiates new router for controlling user resources

func (*SilencedRouter) Mount

func (r *SilencedRouter) Mount(parent *mux.Router)

Mount the SilencedRouter to a parent Router

type TessenController

type TessenController interface {
	CreateOrUpdate(context.Context, *corev2.TessenConfig) error
	Get(context.Context) (*corev2.TessenConfig, error)
}

TessenController represents the controller needs of the TessenRouter.

type TessenMetricController

type TessenMetricController interface {
	Publish(context.Context, []corev2.MetricPoint) error
}

TessenMetricController represents the controller needs of the TessenMetricRouter.

type TessenMetricRouter

type TessenMetricRouter struct {
	// contains filtered or unexported fields
}

TessenMetricRouter handles requests for /tessen/metrics.

func NewTessenMetricRouter

func NewTessenMetricRouter(ctrl TessenMetricController) *TessenMetricRouter

NewTessenMetricRouter instantiates a new router for tessen metrics.

func (*TessenMetricRouter) Mount

func (r *TessenMetricRouter) Mount(parent *mux.Router)

Mount the TessenMetricRouter on the given parent Router

type TessenRouter

type TessenRouter struct {
	// contains filtered or unexported fields
}

TessenRouter handles requests for /tessen.

func NewTessenRouter

func NewTessenRouter(ctrl TessenController) *TessenRouter

NewTessenRouter instantiates a new router for tessen.

func (*TessenRouter) Mount

func (r *TessenRouter) Mount(parent *mux.Router)

Mount the TessenRouter on the given parent Router

type UserController

type UserController interface {
	List(ctx context.Context, pred *store.SelectionPredicate) ([]corev2.Resource, error)
	Get(ctx context.Context, name string) (*corev2.User, error)
	Create(ctx context.Context, user *corev2.User) error
	CreateOrReplace(ctx context.Context, user *corev2.User) error
	Disable(ctx context.Context, name string) error
	Enable(ctx context.Context, name string) error
	AddGroup(ctx context.Context, name string, group string) error
	RemoveGroup(ctx context.Context, name string, group string) error
	RemoveAllGroups(ctx context.Context, name string) error
}

UserController represents the controller needs of the UsersRouter.

type UsersRouter

type UsersRouter struct {
	// contains filtered or unexported fields
}

UsersRouter handles requests for /users

func NewUsersRouter

func NewUsersRouter(store store.Store) *UsersRouter

NewUsersRouter instantiates new router for controlling user resources

func (*UsersRouter) Mount

func (r *UsersRouter) Mount(parent *mux.Router)

Mount the UsersRouter to a parent Router

type VersionController

type VersionController interface {
	GetVersion(ctx context.Context) *corev2.Version
}

VersionController represents the controller needs of the VersionRouter

type VersionRouter

type VersionRouter struct {
	// contains filtered or unexported fields
}

VersionRouter handles requests for /version

func NewVersionRouter

func NewVersionRouter(ctrl VersionController) *VersionRouter

NewVersionRouter instantiates new router for controlling version information

func (*VersionRouter) Mount

func (r *VersionRouter) Mount(parent *mux.Router)

Mount the VersionRouter to a parent Router

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL