shadowproxy

package module
v0.0.0-...-0349834 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: MIT Imports: 10 Imported by: 0

README

Krakend Shadowproxy Middleware

This package contains custom middleware to add a shadow backend to a KrakenD proxy pipe. It can be used to mirror proxy requests to a secondary backend, similar to KrakenD's inbuilt shadow functionality (which does not support proxy requests).

Installation

To install shadowproxy from GitHub:

go get -u github.com/kivra/krakend-shadowproxy@<commit hash>

Quick Start

Using the following configuration, an incoming request to KrakenD's /v1/user/123 endpoint is proxied to https://my.backend.com/v2/user/123, together with a shadow request to https://other.backend.com/v3/user/123. The return value of the shadow request is ignored.

"endpoints": [
  {
    "endpoint": "/v1/user/{ukey}",
    "method": "POST",
    "output_encoding": "no-op",
    "extra_config": {
      "kivra/shadowproxy": {
        "host": [ "https://other.backend.com" ],
        "url_pattern": "/v3/user/{ukey}",
        "method": "POST"
      }
    },
    "backend": [
      {
        "host": [ "https://my.backend.com" ],
        "url_pattern": "/v2/user/{ukey}",
        "method": "POST",
        "encoding": "no-op"
      }
    ]
  }
]

Configuration Options

The middleware configuration supports the following parameters.


host

The host URL(s) of the backend(s) that will receive the shadow request.


url_pattern

The URL pattern used for requests to the shadow backend.


method (optional)

The request method used for requests to the shadow backend (default "GET").


disable_host_sanitize (optional)

Disable host sanitization for prodived host list (default false).


timeout (optional)

The timeout for the request to the shadow backend as a Go duration, for example 10s. Defaults to the endpoint timeout.

Documentation

Index

Constants

View Source
const Namespace = "kivra/shadowproxy"

Variables

This section is empty.

Functions

func ProxyFactory

func ProxyFactory(pf proxy.Factory) proxy.FactoryFunc

Types

type ProxyConfig

type ProxyConfig struct {
	Host                     []string
	URLPattern               string
	Method                   string
	HostSanitizationDisabled bool
	Timeout                  time.Duration
}

Jump to

Keyboard shortcuts

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