traefik_enforce_header_case_plugin

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: MIT Imports: 3 Imported by: 0

README

Traefik Enforce Header Case Plugin

Build Status Latest Release

A Traefik middleware plugin which enforces the case of specified request headers.

This overrides Go (and, by extension, Traefik)'s default behaviour of canonicalising header keys, which can be useful when working with HTTP servers/applications that are case-sensitive to certain headers.

Configuration

Static
experimental:
  plugins:
    enforceHeaderCase:
      moduleName: github.com/clugg/traefik-enforce-header-case-plugin
      version: v0.1.0
Dynamic

In the following example, a router has been set up with middleware set up to ensure that the x-tEsT-hEAder header is always forwaded to the service exactly as it appears in the configuration. This means that if a request containing this header is made to the router with any variation of casing (e.g. x-test-header: 123 or X-TEST-HEADER: 123), the request forwarded to the service will contain x-tEsT-hEAder: 123.

http:
  middlewares:
    enforce-header-case:
      plugin:
        enforceHeaderCase:
          headers:
            - x-tEsT-hEAder

  routers:
    my-router:
      rule: Host(`localhost`)
      service: my-service
      middlewares:
        - enforce-header-case@file

  services:
    my-service:
      loadBalancer:
        servers:
          - url: 'http://127.0.0.1'

Documentation

Overview

Package traefik_enforce_header_case_plugin A Traefik middleware plugin which enforces the case of specified request headers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, next http.Handler, config *Config, name string) (http.Handler, error)

New creates a new TraefikEnforceHeaderCaseMiddleware plugin.

Types

type Config

type Config struct {
	Headers []string `json:"headers,omitempty"`
}

Config plugin configuration.

func CreateConfig

func CreateConfig() *Config

CreateConfig creates an empty plugin configuration.

type TraefikEnforceHeaderCaseMiddleware

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

TraefikEnforceHeaderCaseMiddleware plugin.

func (*TraefikEnforceHeaderCaseMiddleware) ServeHTTP

Jump to

Keyboard shortcuts

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