Documentation ¶
Overview ¶
Package http provides the API server and its corresponding components.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrDenyAllKey = fmt.Errorf("api key is not valid")
ErrDenyAllKey is defined by the default middleware denying all incoming requests.
Functions ¶
func APIKeyMiddleware ¶
func APIKeyMiddleware(apiKey APIKeyRepository) func(next echo.HandlerFunc) echo.HandlerFunc
APIKeyMiddleware is the middleware for validating API keys.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is the API server.
type APIKeyRepository ¶
type APIKeyRepository interface { // Validate validates an API key. If the API Key is valid, // a user ID is returned. Otherwise an error is returned. Validate(ctx context.Context, key string) (uuid.UUID, error) }
APIKeyRepository is the interface for API key repositories.
type Options ¶
type Options struct { Port int ShutdownDelay time.Duration Logger *slog.Logger Runnables []Runnable WithAuthEnabled bool APIKeyRepository APIKeyRepository }
Options represents the options for the API.
type Opts ¶
type Opts func(*Options)
Opts represents a function that modifies the options.
func WithAuthEnabled ¶
func WithAuthEnabled(apiKeyRepository APIKeyRepository) Opts
WithAuthEnabled enables authentication with a given api key repository.
func WithShutdownDelay ¶
WithShutdownDelay sets the shutdown delay.
Directories ¶
Path | Synopsis |
---|---|
Package api provides primitives to interact with the openapi HTTP API.
|
Package api provides primitives to interact with the openapi HTTP API. |
Package handlers implements the handlers for the API server.
|
Package handlers implements the handlers for the API server. |
Click to show internal directories.
Click to hide internal directories.