rule

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRuleTypeRequired   = errors.New("rule type is required")
	ErrPatternRequired    = errors.New("pattern is required")
	ErrProxyGroupRequired = errors.New("proxy group is required")
	ErrInvalidProxyGroup  = errors.New("invalid proxy group")
)
View Source
var ErrNotFound = errors.New("rule not found")

Functions

This section is empty.

Types

type CreateRuleInput

type CreateRuleInput struct {
	RuleType   string `json:"rule_type"`
	Pattern    string `json:"pattern"`
	ProxyGroup string `json:"proxy_group"`
}

type CreateRuleRecord

type CreateRuleRecord struct {
	RuleType     string
	Pattern      string
	TargetKind   string
	ProxyGroupID sql.NullInt64
}

type Handler

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

func NewHandler

func NewHandler(service *Service) *Handler

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(mux *http.ServeMux)

type ImportRulesInput

type ImportRulesInput struct {
	Rules   string `json:"rules"`
	Reverse bool   `json:"reverse"`
}

type ImportRulesResult

type ImportRulesResult struct {
	Imported int `json:"imported"`
	Skipped  int `json:"skipped"`
}

type ListRulesInput

type ListRulesInput struct {
	Page     int
	PageSize int
	Search   string
}

type ListRulesResult

type ListRulesResult struct {
	Rules    []Rule `json:"rules"`
	Page     int    `json:"page"`
	PageSize int    `json:"page_size"`
	Total    int    `json:"total"`
}

type Repository

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

func NewRepository

func NewRepository(db *sql.DB) *Repository

func (*Repository) BatchImport

func (r *Repository) BatchImport(ctx context.Context, records []CreateRuleRecord) (int, error)

func (*Repository) Create

func (r *Repository) Create(ctx context.Context, rec CreateRuleRecord) (Rule, error)

func (*Repository) Delete

func (r *Repository) Delete(ctx context.Context, id int64) error

func (*Repository) FindProxyGroupIDByName

func (r *Repository) FindProxyGroupIDByName(ctx context.Context, name string) (int64, error)

func (*Repository) GetByID

func (r *Repository) GetByID(ctx context.Context, id int64) (Rule, error)

func (*Repository) List

func (r *Repository) List(ctx context.Context, in ListRulesInput) ([]Rule, int, error)

func (*Repository) ListAscendingForOutput

func (r *Repository) ListAscendingForOutput(ctx context.Context) ([]RuleOutputRow, error)

func (*Repository) ListForInternalGroup

func (r *Repository) ListForInternalGroup(ctx context.Context, groupID int64) ([]string, error)

func (*Repository) ListForOutput

func (r *Repository) ListForOutput(ctx context.Context) ([]string, error)

func (*Repository) Update

func (r *Repository) Update(ctx context.Context, id int64, rec CreateRuleRecord) (Rule, error)

type Rule

type Rule struct {
	ID         int64     `json:"id"`
	RuleType   string    `json:"rule_type"`
	Pattern    string    `json:"pattern"`
	ProxyGroup string    `json:"proxy_group"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
}

type RuleOutputRow

type RuleOutputRow struct {
	ID             int64
	RuleType       string
	Pattern        string
	TargetKind     string
	ProxyGroupID   sql.NullInt64
	ProxyGroupName sql.NullString
}

type Service

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

func NewService

func NewService(repo *Repository) *Service

func (*Service) Create

func (s *Service) Create(ctx context.Context, in CreateRuleInput) (Rule, error)

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, id int64) error

func (*Service) GetByID

func (s *Service) GetByID(ctx context.Context, id int64) (Rule, error)

func (*Service) Import

func (*Service) List

func (*Service) Update

func (s *Service) Update(ctx context.Context, id int64, in UpdateRuleInput) (Rule, error)

type UpdateRuleInput

type UpdateRuleInput struct {
	RuleType   string `json:"rule_type"`
	Pattern    string `json:"pattern"`
	ProxyGroup string `json:"proxy_group"`
}

Jump to

Keyboard shortcuts

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