Documentation
¶
Overview ¶
Package httpserver is the HTTP entry of ermite: the router, the security headers, the request log and the graceful shutdown. Routes are added here as the other adapters arrive: /-/health and the routes given in Config.
Index ¶
Constants ¶
View Source
const APIPrefix = "/-/api"
APIPrefix is where the API is mounted.
View Source
const ShutdownTimeout = 10 * time.Second
ShutdownTimeout is how long Run waits for requests in flight after the context ends.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Check ¶
Check reports whether a dependency works. A nil result means healthy.
func DirWritable ¶
DirWritable returns a Check that creates and removes a file in dir.
type Config ¶
type Config struct {
// Addr is the listen address, "host:port".
Addr string
// PublicURL is the public base URL of the server. When it is https://,
// every response carries Strict-Transport-Security.
PublicURL string
// HealthChecks run on GET /-/health, at most once per healthCacheTTL
// (the answer is cached, the endpoint being unauthenticated); one
// failure answers 503.
HealthChecks []Check
// Routes are added to the router next to /-/health.
Routes []Route
// API serves the ConnectRPC API under /-/api/ (the prefix is stripped, so
// it sees "/ermite.RepoService/ListRepos"). Nil serves none.
API http.Handler
// OnShutdown functions run, each in its own goroutine, when the graceful
// shutdown begins. Use them to end long-lived responses such as event
// streams, which the shutdown would otherwise wait for.
OnShutdown []func()
}
Config configures a Server.
type Route ¶
type Route struct {
// Pattern is a net/http.ServeMux pattern, such as "GET /{repo}/info/refs".
// It must not overlap the /-/ routes of the server.
Pattern string
Handler http.Handler
}
Route mounts a handler on the router.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the HTTP server of ermite.
Click to show internal directories.
Click to hide internal directories.