Documentation
¶
Index ¶
- Constants
- func NewEndpointMetaCtx(ctx context.Context, endpointMeta *EndpointMetadata) context.Context
- func NewRequestScopeCtx(ctx context.Context, reqScopes map[types.PermissionScope]*RequestAction) context.Context
- type APIEndpoint
- type APIEndpointFactory
- type APIObjectEndpointFactory
- type EndpointMetadata
- type EndpointMiddleware
- type EndpointMiddlewareHandler
- type Path
- type RequestAction
Constants ¶
const EndpointMetadataCtxKey = "endpointmetadata"
A context lookup key for retrieving the endpoint metadata
const RequestCtxWebsocketKey = "websocket"
A context lookup key for attaching a websocket read writer to context
const RequestScopeCtxKey = "requestscopes"
A context lookup key for determining which scopes are part of this endpoint
Variables ¶
This section is empty.
Functions ¶
func NewEndpointMetaCtx ¶
func NewEndpointMetaCtx(ctx context.Context, endpointMeta *EndpointMetadata) context.Context
func NewRequestScopeCtx ¶
func NewRequestScopeCtx(ctx context.Context, reqScopes map[types.PermissionScope]*RequestAction) context.Context
Types ¶
type APIEndpoint ¶
type APIEndpoint struct {
Metadata *EndpointMetadata
DecoderValidator handlerutils.RequestDecoderValidator
Writer handlerutils.ResultWriter
}
APIEndpoint contains the implementation of a Hatchet API endpoint, including which decoder, validator, and writer to use.
type APIEndpointFactory ¶
type APIEndpointFactory interface {
NewAPIEndpoint(metadata *EndpointMetadata) *APIEndpoint
GetDecoderValidator() handlerutils.RequestDecoderValidator
GetResultWriter() handlerutils.ResultWriter
}
APIEndpointFactory contains common methods for generating an API endpoint from a shared set of metadata. All server endpoints should likely use the DefaultAPIEndpointFactory, this abstraction is mostly for testing purposes.
func NewAPIObjectEndpointFactory ¶
func NewAPIObjectEndpointFactory(conf *server.Config) APIEndpointFactory
type APIObjectEndpointFactory ¶
type APIObjectEndpointFactory struct {
DecoderValidator handlerutils.RequestDecoderValidator
ResultWriter handlerutils.ResultWriter
}
func (*APIObjectEndpointFactory) GetDecoderValidator ¶
func (factory *APIObjectEndpointFactory) GetDecoderValidator() handlerutils.RequestDecoderValidator
func (*APIObjectEndpointFactory) GetResultWriter ¶
func (factory *APIObjectEndpointFactory) GetResultWriter() handlerutils.ResultWriter
func (*APIObjectEndpointFactory) NewAPIEndpoint ¶
func (factory *APIObjectEndpointFactory) NewAPIEndpoint( metadata *EndpointMetadata, ) *APIEndpoint
type EndpointMetadata ¶
type EndpointMetadata struct {
// The API verb that this endpoint should use
Verb types.APIVerb
// The underlying HTTP method that this endpoint should use
Method types.HTTPVerb
// The constructed path for the endpoint
Path *Path
// A list of scopes required for the endpoint
Scopes []types.PermissionScope
// Whether the endpoint upgrades to a websocket
IsWebsocket bool
// Whether the endpoint should check for a usage limit
CheckUsage bool
// The usage metric that the request should check for, if CheckUsage
UsageMetric types.UsageMetric
// AllowUnverifiedEmails controls whether or not the endpoint should permit authenticated
// users with unverified email addresses
AllowUnverifiedEmails bool
// (optional) ContentType describes the content type for the endpoint. If unspecified, it's
// registered as application/json;utf8.
ContentType string
}
EndpointMetadata contains information about the endpoint, such as the API verb and scopes reqiured to call this endpoint successfully.
type EndpointMiddleware ¶
type EndpointMiddleware struct {
// contains filtered or unexported fields
}
func NewEndpointMiddleware ¶
func NewEndpointMiddleware( config *server.Config, endpoint *EndpointMetadata, ) *EndpointMiddleware
func (*EndpointMiddleware) Middleware ¶
func (p *EndpointMiddleware) Middleware(next http.Handler) http.Handler
type EndpointMiddlewareHandler ¶
type EndpointMiddlewareHandler struct {
// contains filtered or unexported fields
}
func (*EndpointMiddlewareHandler) ServeHTTP ¶
func (h *EndpointMiddlewareHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Path ¶
type Path struct {
// The parent path
Parent *Path
// The relative path from the parent
RelativePath string
}
Path represents the path of an endpoint