go_handlers

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSinglePageAppHandler

func NewSinglePageAppHandler(embedFs fs.FS, embedPath string) (http.Handler, error)

NewSinglePageAppHandler returns an HTTP handler for serving a single-page application.

In regular builds, the handler serves files from the provided embedFs, which generally should be an embed.FS. In debug builds (activated via the -tags debug flag), it attempts to locate and serve static assets from the file system using the provided embedPath.

Parameters:

  • embedFs: an fs.FS providing the embedded static assets.
  • embedPath: a relative file path to the static assets, used only in debug mode.

Returns:

  • http.Handler: a handler that serves static files if they exist, or falls back to serving the root file (typically index.html) when a file is not found.
  • error: an error value if the handler cannot be instantiated in debug mode; nil otherwise.

Types

This section is empty.

Jump to

Keyboard shortcuts

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