headers_middleware

command
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Example of request/response header manipulation using a middleware.

Header Manipulation Example

This example shows how to use the new request header manipulation features alongside existing response header functionality:

1. Request Header Operations:

  • Remove potentially sensitive headers (X-Forwarded-For)
  • Add custom request headers (X-Internal-Request)
  • Set specific request headers (X-Request-Source)

2. Response Header Operations:

  • Add security headers (X-Frame-Options)
  • Set custom API headers (X-API-Version)
  • Remove server identification headers (Server)

3. Header Inspection Route:

  • Displays all request headers received by the handler
  • Shows how request headers are modified before reaching handlers
  • Demonstrates response headers are added after handler execution

The middleware processes headers in this order: Request: remove → set → add (before calling handler) Response: remove → set → add (after handler returns)

Jump to

Keyboard shortcuts

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