route

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	Service service.Service `config:"service"`
}

func (*Backend) GetService added in v1.6.0

func (b *Backend) GetService() *service.Service

GetService returns a single service (backward compatibility method) Returns the first server if in multi-server mode

func (*Backend) IsMultiServer added in v1.6.0

func (b *Backend) IsMultiServer() bool

IsMultiServer checks if the backend is configured for multi-server mode

func (*Backend) Normalize added in v1.6.0

func (b *Backend) Normalize() *NormalizedBackend

Normalize converts the Backend to a NormalizedBackend If only a single Service is configured, it automatically converts to multi-server mode

type NormalizedBackend added in v1.6.0

type NormalizedBackend struct {
	Algorithm  string
	Servers    []*service.Server
	BaseConfig *service.Service
}

NormalizedBackend represents a normalized backend configuration that can handle both single-server and multi-server modes

type RateLimit added in v1.7.0

type RateLimit struct {
	Enable    bool              `config:"enable"`
	Algorithm string            `config:"algorithm,default=token-bucket"` // token-bucket, leaky-bucket, fixed-window
	KeyType   string            `config:"key_type,default=ip"`            // ip, user, apikey, clientid, header
	KeyHeader string            `config:"key_header"`                     // when key_type=header, specify header name
	Limit     int64             `config:"limit"`                          // limit count
	Window    int64             `config:"window"`                         // time window in seconds
	Burst     int64             `config:"burst"`                          // burst capacity (only for token-bucket)
	Message   string            `config:"message,default=Too Many Requests"`
	Headers   map[string]string `config:"headers"` // custom response headers
}

type Route

type Route struct {
	Name    string  `config:"name"`
	Path    string  `config:"path"`
	Backend Backend `config:"backend"`
	// PathType is the path type of route, options: prefix, regex
	PathType  string    `config:"path_type,default=prefix"`
	RateLimit RateLimit `config:"rate_limit"`
}

func (*Route) Rewrite

func (r *Route) Rewrite(path string) string

type Service added in v1.4.1

type Service = service.Service

Jump to

Keyboard shortcuts

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