fileprovider

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package fileprovider provides a file-based discovery provider.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Version    string              `yaml:"version"`
	NotMatched *Respond            `yaml:"not-matched"`
	Rules      []Rule              `yaml:"rules"`
	Upstreams  map[string]Upstream `yaml:"upstreams"`
}

Config defines a set of rules for the proxy to use.

type File

type File struct {
	FileName      string
	CheckInterval time.Duration
	Delay         time.Duration
}

File discovers the changes in routing rules from a file.

func (*File) Events

func (d *File) Events(ctx context.Context) <-chan string

Events checks whether the file has been changed.

func (*File) Name

func (d *File) Name() string

Name returns the name of the provider.

func (*File) State added in v0.3.0

func (d *File) State(ctx context.Context) (*discovery.State, error)

State parses the file and returns the current state of the provider.

type Forward added in v0.3.0

type Forward struct {
	Upstream string            `yaml:"upstream"`
	Header   map[string]string `yaml:"header"`
}

Forward specifies how the service should forward the request.

type Respond

type Respond struct {
	Body     *string `yaml:"body"`
	Metadata *struct {
		Header  map[string]string `yaml:"header"`
		Trailer map[string]string `yaml:"trailer"`
	} `yaml:"metadata"`
	Status *struct {
		Code    string `yaml:"code"`
		Message string `yaml:"message"`
	} `yaml:"status"`
}

Respond specifies how the service should respond to the request.

type Rule

type Rule struct {
	Match struct {
		URI    string            `yaml:"uri"`
		Header map[string]string `yaml:"header"`
		Body   *string           `yaml:"body"`
	} `yaml:"match"`
	Respond *Respond `yaml:"respond,omitempty"`
	Forward *Forward `yaml:"forward,omitempty"`
}

Rule specifies a route matching rule.

type Upstream added in v0.3.0

type Upstream struct {
	Addr            string `yaml:"address"`
	TLS             bool   `yaml:"tls"`
	ServeReflection bool   `yaml:"serve-reflection"`
}

Upstream specifies a service to forward requests to.

Jump to

Keyboard shortcuts

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