traefik_upstream_when

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

README

Configuration

For each plugin, the Traefik static configuration must define the module name (as is usual for Go packages).

The following declaration (given here in YAML) defines an plugin:

# Static configuration

experimental:
  plugins:
    upstreamFirst:
      moduleName: github.com/PandaWorker/traefik-upstream-when
      version: v0.1.1

Here is an example of a file provider dynamic configuration (given here in YAML), where the interesting part is the http.middlewares section:

# Dynamic configuration

http:
  routers:
    my-router:
      rule: host(`demo.localhost`)
      service: service-foo
      entryPoints:
        - web
      middlewares:
        - my-plugin

  services:
   service-foo:
      loadBalancer:
        servers:
          - url: http://127.0.0.1:5000
  
  middlewares:
    my-plugin:
      upstreamFirst:
        UpstreamUrl: http://127.0.0.1:5001
        UpstreamStatus:
          - 200

Dev Mode

The Traefik static configuration must define a plugin name, a GoPath, and the module name (as is usual for Go packages).

# Static configuration

experimental:
  devPlugin:
    goPath: /plugins/go
    moduleName: github.com/PandaWorker/traefik-upstream-when

Documentation

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 instantiates and returns the required components used to handle an HTTP request

Types

type Config

type Config struct {
	UpstreamUrl       string `yaml:"UpstreamUrl"`
	UpstreamStatus    []int  `yaml:"UpstreamStatus"`
	UpstreamOnMatch   bool   `yaml:"UpstreamOnMatch,omitempty"`
	UpstreamEnableH2C bool   `yaml:"UpstreamEnableH2C,omitempty"`
}

func CreateConfig

func CreateConfig() *Config

type PluginConfig added in v0.1.4

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

func CreatePluginConfig added in v0.1.4

func CreatePluginConfig() *PluginConfig

func PluginConfigFromConfig added in v0.1.4

func PluginConfigFromConfig(config *Config) (*PluginConfig, error)

func (*PluginConfig) GetTransport added in v0.1.5

func (pcnf *PluginConfig) GetTransport() http.RoundTripper

type UpstreamWhenPlugin

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

func (*UpstreamWhenPlugin) Close added in v0.1.4

func (uwp *UpstreamWhenPlugin) Close() error

func (*UpstreamWhenPlugin) ServeHTTP

func (uwp *UpstreamWhenPlugin) ServeHTTP(rw http.ResponseWriter, originalRequest *http.Request)

Jump to

Keyboard shortcuts

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