Documentation
¶
Overview ¶
Package api contains the HTTP endpoints of the Karman API. We use the github.com/go-chi/chi router. Every collection of endpoints is implemented as a Handler type that exposes a Router function compatible with Chi's Route function. Many handlers contain sub-handlers from their respective sub-packages.
Package api also contains some utility packages that are used across API endpoints. These include consistent error messages and middlewares used across the API.
Index ¶
- type Handler
- func (h *Handler) Healthz(w http.ResponseWriter, r *http.Request)
- func (*Handler) MethodNotAllowed(w http.ResponseWriter, r *http.Request)
- func (*Handler) NotAcceptable(w http.ResponseWriter, r *http.Request)
- func (*Handler) NotFound(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type HealthChecker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is the main API handler. This is basically the root entrypoint of the Karman API. All other API endpoints are created as sub-handlers of this controller.
func NewHandler ¶
func NewHandler( logger *slog.Logger, requestLogger *slog.Logger, hc HealthChecker, songRepo song.Repository, songSvc song.Service, mediaSvc media.Service, mediaStore media.Store, uploadRepo upload.Repository, uploadStore upload.Store, debug bool, ) *Handler
NewHandler creates a new Handler instance using the specified dependencies. The injected dependencies are passed along to the sub-handlers. debug indicates whether additional debugging features should be enabled.
func (*Handler) Healthz ¶
func (h *Handler) Healthz(w http.ResponseWriter, r *http.Request)
Healthz implements the /healthz endpoint.
func (*Handler) MethodNotAllowed ¶
func (*Handler) MethodNotAllowed(w http.ResponseWriter, r *http.Request)
MethodNotAllowed is an HTTP endpoint that renders a generic 405 Method Not Allowed error. This endpoint is the default 405 endpoint for the Handler and its sub-handlers.
func (*Handler) NotAcceptable ¶
func (*Handler) NotAcceptable(w http.ResponseWriter, r *http.Request)
NotAcceptable is an HTTP endpoint that renders a generic 406 Not Acceptable error. This endpoint is the default 406 endpoint fo the Handler and its sub-handlers.
type HealthChecker ¶
type HealthChecker interface { // HealthCheck performs a health check and returns its result. // A result of true indicates that the system is healthy. HealthCheck(ctx context.Context) bool }
HealthChecker is an interface that can provide information about the system health.
Directories
¶
Path | Synopsis |
---|---|
Package apierror provides two things: an implementation of [RFC 9457] and convenience functions that generate the errors returned by the Karman API.
|
Package apierror provides two things: an implementation of [RFC 9457] and convenience functions that generate the errors returned by the Karman API. |
Package middleware provides some of the middlewares used in the Karman API.
|
Package middleware provides some of the middlewares used in the Karman API. |
Package schema contains HTTP request and response schemas used throughout the Karman API.
|
Package schema contains HTTP request and response schemas used throughout the Karman API. |