Skip to content

Traefik middleware to add a header with the value of a given URL query parameter

License

Notifications You must be signed in to change notification settings

corticph/queryparameter-to-header

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QueryParameter-to-Header Middleware

Traefik middleware to add a header with the value of a given URL query parameter

queryParameter and header keys are configurable. It is assummed that there is only one query parameter with the given key. If there are several, the first one in the query string is chosen. If there is no matching query parameter, no header is added.

Tested with Traefik v2.6.3.

Example Traefik config:

[...]
experimental:
  plugins:
    queryParameterToHeader:
      moduleName: github.com/corticph/queryparameter-to-header
      version: v1.0.0

http:
[...]
  routers:
    whoami:
      rule: "Host(`whoami.localhost`)"
      service: "whoami"
      entryPoints:
        - web
      middlewares:
        - add-header-from-query
  
  middlewares:
    add-header-from-query:
      plugin:
        queryParameterToHeader:
          queryParameter: "v"
          header: "X-Version"

About

Traefik middleware to add a header with the value of a given URL query parameter

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages