Documentation
¶
Overview ¶
Package httpapi serves the public HTTP API, following its contract (api/openapi.yaml): the server and its timeouts, the probes, and the middleware every request goes through (request identifier, access log, panic recovery, security headers). It never serves HTML: every error is an RFC 9457 problem.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHandler ¶
NewHandler returns the handler of the API: its routes behind the request middleware.
Types ¶
type Checker ¶ added in v0.35.0
type Checker interface {
// Check returns the report of in; a source it could not consult is
// reported unavailable, never an error.
Check(ctx context.Context, in domain.Input) domain.Report
// CheckAll returns the report of each input, in the order of ins.
CheckAll(ctx context.Context, ins []domain.Input) []domain.Report
}
Checker checks an input against the sources.
type Options ¶
type Options struct {
// Ready backs /readyz.
Ready Readiness
// Check backs /v1/check and /v1/check/batch.
Check Checker
// Sources backs /v1/sources.
Sources SourceLister
// Logger receives the access log and the recovered panics.
Logger *slog.Logger
// NewID makes a request identifier when the client sent no valid one;
// nil means crypto/rand.Text.
NewID func() string
// ProblemBase is the URL of the documentation of the problems, ending
// with a slash: the type of a problem is its code under it.
ProblemBase string
// BatchMaxItems is the most items POST /v1/check/batch accepts, at
// least one: config.Config.BatchMaxItems.
BatchMaxItems int
}
Options configures the handler.
type Readiness ¶
type Readiness interface {
// Ready reports whether every snapshot is loaded.
Ready() bool
}
Readiness tells whether the API can answer checks.
type SourceLister ¶ added in v0.37.0
type SourceLister interface {
// Sources returns every source and the state of its data in service.
Sources() []app.ListedSource
}
SourceLister lists the sources a check consults.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package contracttest checks HTTP exchanges against the public contract, api/openapi.yaml.
|
Package contracttest checks HTTP exchanges against the public contract, api/openapi.yaml. |
Click to show internal directories.
Click to hide internal directories.