dynamicheaders

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

README

dynamic-headers

dynamic caddy server headers middleware.

build Caddy with dynamic headers module

xcaddy build --output ./caddy.exe --with github.com/c1pca/dynamic-headers

{
  "logging": {
    "logs": {
      "default": {
        "level": "DEBUG"
      }
    }
  },
  "apps": {
    "http": {
      "servers": {
        "myserver": {
          "listen": [":448",":87"],
          "routes": [
            {
              "match": [{"path": ["/*"]}],
              "handle": [
                {
                  "handler": "dynamic_headers",
                  "to_header": "test_dynamic_header_1",
                  "from_header": "Connection", // optional parameter
                  "take_host": true
                },
                {
                "handler": "reverse_proxy",
                "headers": {
                  "request": {
                    "set": {
                      "X-Static-Header": [
                        "test-static-Header"
                      ]
                    }
                  }
                },
                "upstreams": [{
                  "dial": "localhost:445"
                }]
                }
              ]
            }
          ],
          "logs": {
            "should_log_credentials": true
          }
        }
      }
    }
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DynamicHeaders

type DynamicHeaders struct {
	// The file or stream to write to. Can be "stdout"
	// or "stderr".
	TakeHost   bool   `json:"take_host"`
	ToHeader   string `json:"to_header,omitempty"`
	FromHeader string `json:"from_header"`
	// contains filtered or unexported fields
}

DynamicHeaders Middleware implements an HTTP handler that writes headers dynamically.

func (DynamicHeaders) CaddyModule

func (DynamicHeaders) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*DynamicHeaders) Provision

func (m *DynamicHeaders) Provision(ctx caddy.Context) error

Provision implements caddy.Provisioner.

func (DynamicHeaders) ServeHTTP

ServeHTTP implements caddyhttp.MiddlewareHandler.

func (*DynamicHeaders) UnmarshalCaddyfile

func (m *DynamicHeaders) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile implements caddyfile.Unmarshaler.

func (*DynamicHeaders) Validate

func (m *DynamicHeaders) Validate() error

Validate implements caddy.Validator.

Jump to

Keyboard shortcuts

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