Documentation
¶
Overview ¶
Package config advertises a server's configuration, at /config.json, to its frontend: the path prefix of its API, its name, its version, where the API's documentation is, and its public endpoint, when it has one
Index ¶
Constants ¶
const ( // Path is where the configuration is served, which is beside the // frontend, rather than beneath the API's prefix, which it says Path = "/config.json" // Tag is the configuration's tag, which a server with tag groups adds to // one of them, as Redoc doesn't show a tag which isn't in a group Tag = "Config" )
Variables ¶
This section is empty.
Functions ¶
func PublicEndpoint ¶
PublicEndpoint returns the URL, when it's https, as it is when the server was given its public name, without a slash at its end, or none
func RegisterHandler ¶
func RegisterHandler(router *httprouter.Router, config Config) error
RegisterHandler registers the configuration with the router, at Path, with Tag
Types ¶
type Config ¶
type Config struct {
Prefix string `json:"prefix" help:"Path prefix of the API, such as /api"`
Name string `json:"name,omitempty" help:"Name of the server, such as its command"`
Version string `json:"version,omitempty" help:"Version of the server"`
OpenAPI string `json:"openapi,omitempty" help:"Path of the API's documentation, when it's served"`
// The server's public endpoint, such as https://example.com/api, when it
// was given its public name, such as that of a proxy it's behind, with
// --tls.name, so it's https, or none, when it wasn't, as its own URL is
// then its listen address, which its frontend can't always reach
Endpoint string `` /* 142-byte string literal not displayed */
}
Config is a server's configuration, which its frontend reads from /config.json, so it knows where the API is
func New ¶
New returns the configuration of the server which the command runs, with the router's prefix, the command's name and version, the path of the API's documentation, when openapi is true, as it's served, and the command's URL, as its public endpoint, when it's https. It's called once the server's URL is known, such as when its routes are registered.