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

middleware

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package middleware is the home of Zinc's standard middleware. Each one is its own package with a New function that takes an optional Config:

app.Use(recover.New(), logger.New(), requestid.New())
app.Use(cors.New(cors.Config{AllowOrigins: []string{"https://app.example.com"}}))

Every package here depends only on Zinc and the standard library. Middleware with third-party dependencies, such as JWT, lives in github.com/0mjs/contrib.

To run a middleware for only some requests, wrap it with zinc.Skip.

Directories

Path Synopsis
Package apidocs serves a browsable reference page for an OpenAPI spec, such as the one every Zinc app serves at /openapi.json.
Package apidocs serves a browsable reference page for an OpenAPI spec, such as the one every Zinc app serves at /openapi.json.
Package compress compresses responses for clients that accept gzip.
Package compress compresses responses for clients that accept gzip.
Package contenttype rejects request bodies of media types or content codings the application does not accept.
Package contenttype rejects request bodies of media types or content codings the application does not accept.
Package headers sets response headers and selects middleware by request header.
Package headers sets response headers and selects middleware by request header.
Package healthcheck answers a health endpoint before routing work.
Package healthcheck answers a health endpoint before routing work.
internal
shared
Package shared holds helpers used by more than one Zinc middleware package.
Package shared holds helpers used by more than one Zinc middleware package.
testutil
Package testutil holds helpers shared by middleware tests.
Package testutil holds helpers shared by middleware tests.
Package limiter bounds how fast, or how many at once, requests reach downstream handlers.
Package limiter bounds how fast, or how many at once, requests reach downstream handlers.
Package logger logs one line per request.
Package logger logs one line per request.
Package nocache tells browsers and intermediaries not to cache responses.
Package nocache tells browsers and intermediaries not to cache responses.
Package pprof serves the net/http/pprof profiling endpoints.
Package pprof serves the net/http/pprof profiling endpoints.
Package prometheus records request counts and durations and serves them in the Prometheus text format, without depending on the Prometheus client.
Package prometheus records request counts and durations and serves them in the Prometheus text format, without depending on the Prometheus client.
Package proxy forwards requests to upstream servers.
Package proxy forwards requests to upstream servers.
Package redirect answers matching paths with a redirect.
Package redirect answers matching paths with a redirect.
Package requestid gives every request an identifier, reusing the one the client or an upstream proxy sent.
Package requestid gives every request an identifier, reusing the one the client or an upstream proxy sent.
Package rewrite routes matching paths as other paths.
Package rewrite routes matching paths as other paths.
Package session keeps string values in a signed client-side cookie.
Package session keeps string values in a signed client-side cookie.
Package trailingslash normalizes trailing slashes in request paths.
Package trailingslash normalizes trailing slashes in request paths.

Jump to

Keyboard shortcuts

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