Documentation ¶
Index ¶
- Variables
- func FalconClient(ctx context.Context, r Request) (*client.CrowdStrikeAPISpecification, error)
- func Fn() struct{ ... }
- func JSON(v any) json.Marshaler
- func RegisterConfigLoader(loaderType string, cr ConfigLoader)
- func RegisterRunner(runnerType string, r Runner)
- func Run[T Cfg](ctx context.Context, newHandlerFn func(_ context.Context, cfg T) Handler)
- type APIError
- type Cfg
- type ConfigLoader
- type Handler
- func ErrHandler(errs ...APIError) Handler
- func HandleFnOf[T any](fn func(context.Context, RequestOf[T]) Response) Handler
- func HandleWorkflow(fn func(context.Context, Request, WorkflowCtx) Response) Handler
- func HandleWorkflowOf[T any](fn func(context.Context, RequestOf[T], WorkflowCtx) Response) Handler
- type HandlerFn
- type Mux
- type Request
- type RequestOf
- type Response
- type Runner
- type SkipCfg
- type WorkflowCtx
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCfgNotFound defines the inability to find a config at the expected location. ErrCfgNotFound = errors.New("no config provided") )
Functions ¶
func FalconClient ¶
FalconClient returns a new instance of the GoFalcon client. If the client cannot be created or if there is no access token in the request, an error is returned.
func RegisterConfigLoader ¶ added in v0.4.0
func RegisterConfigLoader(loaderType string, cr ConfigLoader)
RegisterConfigLoader will register a config loader at the specified type. Similar to registering a database with the database/sql, you're able to provide a config for use at runtime. During Run, the config loader defined by the env var, CS_CONFIG_LOADER_TYPE, is used. If one is not provided, then the fs config loader will be used.
func RegisterRunner ¶ added in v0.4.0
RegisterRunner registers a runner.
Types ¶
type Cfg ¶ added in v0.4.0
type Cfg interface {
OK() error
}
Cfg marks the configuration type parameter. Any config type must have a validation method, OK, defined on it.
type ConfigLoader ¶ added in v0.4.0
ConfigLoader defines the behavior for loading config.
type Handler ¶
Handler provides a handler for our incoming request.
func ErrHandler ¶ added in v0.4.0
func ErrHandler(errs ...APIError) Handler
ErrHandler creates a new handler to resopnd with only errors.
func HandleFnOf ¶ added in v0.4.0
HandleFnOf provides a means to translate the incoming requests to the destination body type. This normalizes the sad path and provides the caller with a zero fuss request to work with. Reducing json boilerplate for what is essentially the same operation on different types.
func HandleWorkflow ¶ added in v0.6.0
HandleWorkflow provides a means to create a handler with workflow integration. This function does not have an opinion on the request body but does expect a workflow integration. Typically, this is useful for DELETE/GET handlers.
func HandleWorkflowOf ¶ added in v0.6.0
HandleWorkflowOf provides a means to create a handler with Workflow integration. This function is useful when you expect a request body and have workflow integrations. Typically, this is with PATCH/POST/PUT handlers.
type HandlerFn ¶ added in v0.4.0
HandlerFn wraps a function to return a handler. Similar to the http.HandlerFunc.
type Mux ¶ added in v0.4.0
type Mux struct {
// contains filtered or unexported fields
}
Mux defines a handler that will dispatch to a matching route/method combination. Much like the std lib http.ServeMux, but with slightly more opinionated route setting. We only support the DELETE, GET, POST, and PUT.
func NewMux ¶ added in v0.4.0
func NewMux() *Mux
NewMux creates a new Mux that is ready for assignment.
func (*Mux) Handle ¶ added in v0.4.0
Handle enacts the handler to process the request/response lifecycle. The mux fulfills the Handler interface and can dispatch to any number of sub routes.
type Request ¶
type Request RequestOf[json.RawMessage]
Request defines a request structure that is given to the runner. The Body is set to json.RawMessage, to enable decoration/middleware.
type RequestOf ¶ added in v0.4.0
type RequestOf[T any] struct { Body T Context json.RawMessage Params struct { Header http.Header Query url.Values } URL string Method string AccessToken string }
RequestOf provides a generic body we can target our unmarshaling into.
type Response ¶
Response is the domain type for the response.
func (Response) StatusCode ¶ added in v0.4.0
StatusCode returns the response status code. When a Response.Code is not set and errors exist, then the highest code on the errors is returned.
type Runner ¶ added in v0.4.0
Runner defines the runtime that executes the request/response handler lifecycle.
type SkipCfg ¶ added in v0.4.0
type SkipCfg struct{}
SkipCfg indicates the config is not needed and will skip the config loading procedure.
type WorkflowCtx ¶ added in v0.6.0
WorkflowCtx is the Request.Context field when integrating a function with Falcon Fusion workflow.