Documentation
¶
Overview ¶
Package stoplightemb provides an embedded (air-gapped) Stoplight Elements UI for stdocs.
Unlike the sibling ui/stoplight package, which loads Stoplight from a CDN at page-load time, ui/stoplightemb vendors the Stoplight web-component bundle in your binary so the docs UI works without an internet connection.
The vendored bundle is pinned to @stoplight/elements@9.0.22.
To use it:
import (
"net/http"
"github.com/FumingPower3925/stdocs"
"github.com/FumingPower3925/stdocs/ui/stoplightemb"
)
mux := stdocs.New(stdocs.WithTitle("My API"), stoplightemb.WithUI())
mux.HandleFunc("GET /x", h)
mux.Mount()
mux.Handle("GET /docs/_assets/", http.StripPrefix(
"/docs/_assets/", stoplightemb.AssetHandler()))
The asset handler adds about 2.4 MB to your binary and is only included if you import this sub-package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssetHandler ¶
AssetHandler returns an http.Handler that serves the embedded Stoplight web components at the root. File responses carry an immutable Cache-Control header; directory requests return 404. Mount it on your mux with a path strip, e.g.:
mux.Handle("GET /docs/_assets/", http.StripPrefix("/docs/_assets/", stoplightemb.AssetHandler()))
Types ¶
This section is empty.