api

API Reference

servejs.NewDir

1
func NewDir(dir string, opts ...Option) http.Handler

Creates a new handler to serve static files from a directory.

servejs.NewFS

1
func NewFS(fs http.FileSystem, opts ...Option) http.Handler

Creates a new handler to serve static files from an http.FileSystem.

Options

  • WithEnvAllowlist([]string)
  • WithEnvExposureMode(EnvExposureMode)
  • WithSPAFallback(bool)
  • WithSecurityHeaders(bool)
  • WithMountPath(string)
  • WithLogger(Logger)

See Configuration Options for details.