Documentation
¶
Overview ¶
Package frontend serves the HTML pages (Go templates + htmx). It has no database: everything else it asks of the backend through the internal API.
Index ¶
- type Frontend
- func (s *Frontend) Close()
- func (s *Frontend) DisableLimits()
- func (s *Frontend) Handler() http.Handler
- func (s *Frontend) RefreshConfig(ctx context.Context) error
- func (s *Frontend) SetAPIHandler(h http.Handler)
- func (s *Frontend) SetAPIUpstream(u *url.URL)
- func (s *Frontend) StartConfigPoll()
- func (s *Frontend) StartListeners(handler http.Handler)
- func (s *Frontend) WaitForBackend(ctx context.Context, timeout time.Duration) error
- func (s *Frontend) WrapListener(ln net.Listener) net.Listener
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Frontend ¶
type Frontend struct {
// Version is shown on the admin page.
Version string
// contains filtered or unexported fields
}
Frontend is the half of the application that renders pages. It has no database and no keys: it asks the backend for everything through api, the internal API over HTTP, and acts only on the few administrator settings the backend hands it (frontendSettings). The Backend is another type, so nothing here can reach its fields.
func NewFrontend ¶
NewFrontend builds a frontend that talks to the backend through api and parses the embedded templates. Call RefreshConfig before serving, and StartConfigPoll to follow changes.
func (*Frontend) Close ¶
func (s *Frontend) Close()
Close cancels the background jobs and waits for them to stop, and stops the HTTPS and HTTP/3 servers. Call it after the HTTP server has been shut down.
func (*Frontend) DisableLimits ¶
func (s *Frontend) DisableLimits()
DisableLimits turns off the request limits of the frontend. The combined process uses it: it has a load budget of its own, shared with the API.
func (*Frontend) RefreshConfig ¶
RefreshConfig fetches the settings from the backend and puts them in force if they changed.
func (*Frontend) SetAPIHandler ¶
SetAPIHandler serves /api/ with h, the public API of a backend in the same process.
func (*Frontend) SetAPIUpstream ¶
SetAPIUpstream makes the frontend pass /api/ on to the backend's public listener, for setups with one public address and no reverse proxy that routes by path. The backend must list this process among its trusted proxies to see visitors' addresses.
func (*Frontend) StartConfigPoll ¶
func (s *Frontend) StartConfigPoll()
StartConfigPoll follows changes to the settings until Close. A backend that is down is not an error here: the frontend keeps the last good settings.
func (*Frontend) StartListeners ¶
StartListeners starts the HTTPS and HTTP/3 servers when the settings ask for them, with handler as their handler (the one the plain server uses). It is called again by reloadSettings whenever a setting changes, which starts, moves or stops them without a restart.
func (*Frontend) WaitForBackend ¶
WaitForBackend fetches the first configuration, retrying until the backend answers or timeout passes, so a frontend started together with its backend does not give up too early.
func (*Frontend) WrapListener ¶
WrapListener makes ln understand the PROXY protocol according to the current settings. Wrap the listener once at start; it costs nothing while the setting is off.
It also remembers the address, which the HTTPS and HTTP/3 servers (tlsserve.go) take their interface from.
Source Files
¶
- api.go
- auth.go
- docs.go
- export.go
- forms.go
- frontend.go
- frontend_session.go
- handlers_admin.go
- handlers_estimates.go
- handlers_import.go
- handlers_legal.go
- handlers_measure.go
- handlers_passkey.go
- handlers_provider.go
- handlers_reset.go
- handlers_security.go
- handlers_serversettings.go
- handlers_settings.go
- handlers_status.go
- handlers_strengthlevel.go
- handlers_tls.go
- handlers_twofactor.go
- handlers_workers.go
- overview.go
- proxyprotocol.go
- server.go
- static.go
- tlsserve.go
- tracking.go
- views.go