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

handler

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 23 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) http.Handler

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

recovery → logging → security → headers (304 check) → compress → file handler

func BuildHandlerQuiet

func BuildHandlerQuiet(cfg *config.Config, c *cache.Cache) http.Handler

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) *FileHandler

NewFileHandler creates a new FileHandler. absRoot is resolved via filepath.Abs so per-request path arithmetic is free of OS syscalls.

func (*FileHandler) ServeHTTP

func (h *FileHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles an HTTP 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