go-http

module
v5.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: BSD-3-Clause

README

go-http

Opinionated package of wrapper, helper and utility functions for working with HTTP-related services.

Documentation

Go Reference

Motivation

There are many wrapper libraries for working with HTTP-related services. This one is mine. It is NOT comprehensive and instead reflects those services which occupy my time or have done so in the past. This is also NOT a "framework". It is a collection of packages and methods designed with "composability" in mind.

Tools

The cmd directory contains example programs and command line tools. Build the command line tools with make cli.

Packages

Top-level packages. Each has its own README with more detail.

Package Description
auth A common interface for enforcing authentication in HTTP handlers, with JWT, OpenID Connect, shared secret, null (always allowed) and none (never allowed) implementations.
bootstrap Middleware and handlers for serving embedded Bootstrap assets and adding references to them to HTML output.
cookie A common interface for reading and writing HTTP cookies, including encrypted cookies.
crumb Generating and validating HTTP crumbs (CSRF tokens), with middleware for assigning and checking them.
fault Handlers and middleware for reporting errors in web applications, optionally rendered with a custom HTML template.
fileserver Handlers and middleware for serving files from a local directory, and a fileserver command line tool.
maps Configuration types and handlers for web maps using Leaflet and Protomaps.
opensearch Types and handlers for publishing OpenSearch description documents and advertising them in HTML output.
response Simple handlers for common responses: null, ping, not implemented and disabled.
rewrite Middleware for rewriting HTTP requests and the HTML content of HTTP responses.
rollup Handlers that bundle and minify multiple JavaScript or CSS files in to a single response.
route An http.Handler that routes requests using http.ServeMux style patterns and initializes the routed handlers lazily.
sanitize Helpers for extracting, sanitising and type-converting query, form and header parameters from HTTP requests.
server A common interface, and registry of implementations, for HTTP servers created from a URI (HTTP(S), mkcert and AWS Lambda).
slog Helpers for deriving log/slog loggers decorated with details of HTTP requests.
static Handlers for serving static assets from an fs.FS and for appending references to those assets to HTML output.
wellknown Packages for working with well-known URIs. Currently webfinger, which defines WebFinger response types.

Directories

Path Synopsis
Package auth provides a common interface for enforcing authentication in HTTP handlers, along with several implementations (JWT, OpenID Connect, shared secret, null and none).
Package auth provides a common interface for enforcing authentication in HTTP handlers, along with several implementations (JWT, OpenID Connect, shared secret, null and none).
Package bootstrap provides middleware and HTTP handlers for serving embedded Bootstrap assets and appending references to them to HTML output.
Package bootstrap provides middleware and HTTP handlers for serving embedded Bootstrap assets and appending references to them to HTML output.
static
Package static contains the embedded Bootstrap CSS and JavaScript assets.
Package static contains the embedded Bootstrap CSS and JavaScript assets.
cmd
auth/example command
Command example is a simple HTTP server that demonstrates using an `auth.Authenticator` to protect a handler.
Command example is a simple HTTP server that demonstrates using an `auth.Authenticator` to protect a handler.
auth/jwt-secret command
Command jwt-secret prints a random string suitable for use as a JWT signing secret.
Command jwt-secret prints a random string suitable for use as a JWT signing secret.
cookie/encrypted-cookie command
Command encrypted-cookie prints a new URI suitable for instantiating an `EncryptedCookie` instance.
Command encrypted-cookie prints a new URI suitable for instantiating an `EncryptedCookie` instance.
crumb/encrypted-crumb command
Command encrypted-crumb prints a new URI suitable for instantiating an `EncryptedCrumb` instance.
Command encrypted-crumb prints a new URI suitable for instantiating an `EncryptedCrumb` instance.
fileserver/fileserver command
Command fileserver serves files from a local directory over HTTP, with optional CORS, gzip, custom content type and custom response header support.
Command fileserver serves files from a local directory over HTTP, with optional CORS, gzip, custom content type and custom response header support.
map-config-example command
Command map-config-example is an example web server that serves a map configuration (at /map.json) and an embedded web application for displaying a map using that configuration.
Command map-config-example is an example web server that serves a map configuration (at /map.json) and an embedded web application for displaying a map using that configuration.
server/example command
Command example starts a simple "Hello, {host}" web server using a `server.Server` instance configured by a URI, optionally returning a 503 Service Unavailable response for all requests.
Command example starts a simple "Hello, {host}" web server using a `server.Server` instance configured by a URI, optionally returning a 503 Service Unavailable response for all requests.
Package cookie provides a common interface for reading and writing HTTP cookies, including cookies whose values are encrypted.
Package cookie provides a common interface for reading and writing HTTP cookies, including cookies whose values are encrypted.
Package crumb provides interfaces and implementations for generating and validating HTTP crumbs (CSRF tokens), along with middleware for assigning and checking them in HTTP handlers.
Package crumb provides interfaces and implementations for generating and validating HTTP crumbs (CSRF tokens), along with middleware for assigning and checking them in HTTP handlers.
Package fault provides HTTP handlers and middleware for reporting errors in web applications, optionally rendering them with a custom HTML template.
Package fault provides HTTP handlers and middleware for reporting errors in web applications, optionally rendering them with a custom HTML template.
Package fileserver provides HTTP handlers and middleware for serving files from a local directory.
Package fileserver provides HTTP handlers and middleware for serving files from a local directory.
Package maps provides configuration types and HTTP handlers for web maps using Leaflet and Protomaps.
Package maps provides configuration types and HTTP handlers for web maps using Leaflet and Protomaps.
static/www
Package www provides an embedded example web application for displaying maps.
Package www provides an embedded example web application for displaying maps.
Package opensearch provides types and HTTP handlers for publishing OpenSearch description documents and advertising them to browsers.
Package opensearch provides types and HTTP handlers for publishing OpenSearch description documents and advertising them to browsers.
Package response provides simple HTTP handlers for common responses.
Package response provides simple HTTP handlers for common responses.
Package rewrite provides middleware for rewriting HTTP requests and the HTML content of HTTP responses.
Package rewrite provides middleware for rewriting HTTP requests and the HTML content of HTTP responses.
Package rollup provides HTTP handlers that combine and minify multiple JavaScript or CSS files into a single response.
Package rollup provides HTTP handlers that combine and minify multiple JavaScript or CSS files into a single response.
Package route provides an `http.Handler` that routes requests using `http.ServeMux` style patterns but defers initializing the handlers being routed to until they are needed.
Package route provides an `http.Handler` that routes requests using `http.ServeMux` style patterns but defers initializing the handlers being routed to until they are needed.
Package sanitize provides helper functions for extracting and sanitising parameters from HTTP requests.
Package sanitize provides helper functions for extracting and sanitising parameters from HTTP requests.
Package server provides a common interface, and a registry of implementations, for HTTP servers that can be instantiated from a URI.
Package server provides a common interface, and a registry of implementations, for HTTP servers that can be instantiated from a URI.
Package slog provides helpers for deriving `log/slog` loggers decorated with details of HTTP requests.
Package slog provides helpers for deriving `log/slog` loggers decorated with details of HTTP requests.
Package static provides handlers for serving static assets from an `fs.FS` instance and for appending references to those assets to HTML output.
Package static provides handlers for serving static assets from an `fs.FS` instance and for appending references to those assets to HTML output.
wellknown
webfinger
Package webfinger defines types and constants for WebFinger (RFC 7033) responses.
Package webfinger defines types and constants for WebFinger (RFC 7033) responses.

Jump to

Keyboard shortcuts

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