Help us shape the future of Go! Take the 2026 Go Developer Survey

handler

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package handler provides the core HTTP file-serving handler and middleware composition for the static web server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildHandler

func BuildHandler(cfg *config.Config, c *cache.Cache, pc ...*security.PathCache) fasthttp.RequestHandler

BuildHandler composes the full middleware chain and returns a ready-to-use fasthttp.RequestHandler. The chain is (outer to inner):

recovery → logging → security → compress → file handler

An optional *security.PathCache may be provided to cache path validation results and skip per-request filesystem syscalls for repeated URL paths.

func BuildHandlerQuiet

func BuildHandlerQuiet(cfg *config.Config, c *cache.Cache, pc ...*security.PathCache) fasthttp.RequestHandler

BuildHandlerQuiet is like BuildHandler but suppresses per-request access logging. Use this when the --quiet flag is set.

Types

type FileHandler

type FileHandler struct {
	// contains filtered or unexported fields
}

FileHandler serves static files from disk with caching and compression support.

func NewFileHandler

func NewFileHandler(cfg *config.Config, c *cache.Cache, pc ...*security.PathCache) *FileHandler

NewFileHandler creates a new FileHandler. absRoot is resolved via filepath.Abs so per-request path arithmetic is free of OS syscalls. An optional *PathCache allows cache-hit requests to resolve the safe filesystem path without a context allocation (PERF-001).

func (*FileHandler) HandleRequest added in v1.3.0

func (h *FileHandler) HandleRequest(ctx *fasthttp.RequestCtx)

HandleRequest handles a fasthttp request by resolving and serving the requested file.

Jump to

Keyboard shortcuts

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