Documentation
¶
Overview ¶
Package scalar provides a Scalar UI for stdocs.
Scalar is a modern OpenAPI viewer loaded from a CDN. To use it, import this sub-package and pass scalar.WithUI() to stdocs.New or stdocs.DocsHandler:
import (
"github.com/FumingPower3925/stdocs"
"github.com/FumingPower3925/stdocs/ui/scalar"
)
mux := stdocs.New(stdocs.WithTitle("My API"), scalar.WithUI())
mux.HandleFunc("GET /x", h)
mux.Mount() // or mount mux.Docs() on a parent mux
This sub-package adds the Scalar HTML to the docs handler. The Scalar JavaScript and CSS are loaded from cdn.jsdelivr.net at page load time, so an internet connection is required.
The CDN URL is pinned to a specific version (1.60.0) and points at the verbatim dist/browser/standalone.js file from the npm package, so its bytes are deterministic and the sha384 SRI hash below is pinned in the <script> tag. Bumping the pinned version requires re-computing the hash. For an air-gapped build, use the ui/scalaremb sub-package instead — it vendors the bundle in-repo.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.