redocemb

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package redocemb provides an embedded (air-gapped) Redoc UI for stdocs.

Unlike the sibling ui/redoc package, which loads Redoc from a CDN at page-load time, ui/redocemb vendors the Redoc JavaScript bundle in your binary so the docs UI works without an internet connection.

The vendored bundle is pinned to redoc@2.5.3 and its sha384 SRI hash is set in the sibling ui/redoc package.

To use it:

import (
    "net/http"
    "github.com/FumingPower3925/stdocs"
    "github.com/FumingPower3925/stdocs/ui/redocemb"
)

mux := stdocs.New(stdocs.WithTitle("My API"), redocemb.WithUI())
mux.HandleFunc("GET /x", h)
mux.Mount()
mux.Handle("GET /docs/_assets/", http.StripPrefix(
    "/docs/_assets/", redocemb.AssetHandler()))

The asset handler adds about 1.1 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

func AssetHandler() http.Handler

AssetHandler returns an http.Handler that serves the embedded Redoc JavaScript bundle 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/", redocemb.AssetHandler()))

func WithUI

func WithUI() stdocs.Option

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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