rule

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RULES_CONFIG_STORAGE_PG   = "postgres"
	RULES_CONFIG_STORAGE_GS   = "gs"
	RULES_CONFIG_STORAGE_FILE = "file"
	RULES_CONFIG_STORAGE_MEM  = "mem"
)

Variables

View Source
var (
	ErrUnknown                  = errors.New("undefined proxy rule")
	ErrUpsertConfigNotSupported = errors.New("upsert rule config is currently not supported")
	ErrInvalidRuleConfig        = errors.New("invalid rule config")
	ErrMarshal                  = errors.New("error while marshalling rule config")
)

Functions

func WithContext

func WithContext(ctx context.Context, rule *Rule) context.Context

Types

type Backend

type Backend struct {
	URL       string `yaml:"url"`
	Namespace string `yaml:"namespace"`
	Prefix    string `yaml:"prefix"`
}

type Config added in v0.6.34

type Config struct {
	ID        uint32
	Name      string
	Config    string
	CreatedAt time.Time
	UpdatedAt time.Time
}

type ConfigRepository

type ConfigRepository interface {
	GetAll(ctx context.Context) ([]Ruleset, error)
	Upsert(ctx context.Context, name string, config Ruleset) (Config, error)
}

type Frontend

type Frontend struct {
	URL   string         `yaml:"url"`
	URLRx *regexp.Regexp `yaml:"-"`

	Method string `yaml:"method"`
}

type HookSpec

type HookSpec struct {
	Name   string                 `yaml:"name"`
	Config map[string]interface{} `yaml:"config"`
}

type HookSpecs

type HookSpecs []HookSpec

func (HookSpecs) Get

func (m HookSpecs) Get(name string) (HookSpec, bool)

type MiddlewareSpec

type MiddlewareSpec struct {
	Name   string                 `yaml:"name"`
	Config map[string]interface{} `yaml:"config"`
}

type MiddlewareSpecs

type MiddlewareSpecs []MiddlewareSpec

func (MiddlewareSpecs) Get

func (m MiddlewareSpecs) Get(name string) (MiddlewareSpec, bool)

type Rule

type Rule struct {
	Frontend    Frontend        `yaml:"frontend"`
	Backend     Backend         `yaml:"backend"`
	Middlewares MiddlewareSpecs `yaml:"middlewares"`
	Hooks       HookSpecs       `yaml:"hooks"`
}

func GetFromContext

func GetFromContext(ctx context.Context) (*Rule, bool)

type Ruleset

type Ruleset struct {
	Rules []Rule `yaml:"rules"`
}

func YamlRulesetToRuleset added in v0.6.34

func YamlRulesetToRuleset(YamlRuleset config.Ruleset) Ruleset

type Service

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

func NewService

func NewService(configRepository ConfigRepository) *Service

func (Service) GetAllConfigs

func (s Service) GetAllConfigs(ctx context.Context) ([]Ruleset, error)

func (Service) UpsertRulesConfigs added in v0.6.34

func (s Service) UpsertRulesConfigs(ctx context.Context, name string, config string) (Config, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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