config

package
v1.8.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 12 Imported by: 4 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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, when it was built, where the API's documentation is, and its public endpoint, when it has one

Index

Constants

View Source
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

func PublicEndpoint(endpoint *url.URL) string

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"`

	// When the server was built, so its frontend knows it's been rebuilt,
	// and offers to refresh the page, even when its version is the same,
	// such as while it's developed
	Build   string `json:"build,omitempty" help:"When the server was built" format:"date-time"`
	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

func New(ctx server.Cmd, router *httprouter.Router, openapi bool) Config

New returns the configuration of the server which the command runs, with the router's prefix, the command's name and version, when it was built, when it's known, 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL