scalar

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

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.59.2) 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

func WithUI

func WithUI() stdocs.Option

WithUI returns a stdocs.Option that replaces the default docs page with the Scalar UI.

Types

This section is empty.

Jump to

Keyboard shortcuts

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