middleware

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package middleware manages Goma Gateway middlewares owned by workspaces and reconciles them into the proxy provider.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNameRequired = errors.New("middleware name is required")
	ErrInvalidName  = errors.New("name must be lowercase letters, digits and hyphens (e.g. basic-auth)")
	ErrTypeRequired = errors.New("middleware type is required")
	ErrNameTaken    = errors.New("a middleware with this name already exists")
	ErrNotFound     = errors.New("middleware not found")
	// ErrInvalidRule re-exports the catalog's validation error so handlers can map
	// it to 422 MIDDLEWARE_INVALID_RULE without importing the catalog package.
	ErrInvalidRule = mwcatalog.ErrInvalidRule
)

Functions

This section is empty.

Types

type Input

type Input struct {
	// Name is the unique slug handle; it must already be canonical slug form (it
	// becomes the Goma middleware name). DisplayName is the free-text label (falls
	// back to Name when blank).
	Name        string
	DisplayName string
	Type        string
	Paths       []string
	Rule        map[string]interface{}
}

type Service

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

func NewService

func NewService(repo *repositories.MiddlewareRepository, syncer WorkspaceSyncer) *Service

func (*Service) Create

func (s *Service) Create(ctx context.Context, workspaceID uint, in Input) (*models.Middleware, error)

func (*Service) Delete

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

func (*Service) Get

func (s *Service) Get(workspaceID, id uint) (*models.Middleware, error)

func (*Service) List

func (s *Service) List(workspaceID uint) ([]models.Middleware, error)

func (*Service) SeedDefaults added in v1.5.0

func (s *Service) SeedDefaults(ctx context.Context, workspaceID uint) error

SeedDefaults creates the workspace's default policy set (mwcatalog.DefaultSeed) in one pass, syncing the proxy once at the end rather than per row. It is a no-op when the workspace already owns any middleware, so it is safe to call again and never clobbers user edits. Best-effort per row: a seed that fails to create (e.g. a name collision from a partial earlier run) is skipped, not fatal.

func (*Service) Update

func (s *Service) Update(ctx context.Context, workspaceID, id uint, in Input) (*models.Middleware, error)

type WorkspaceSyncer

type WorkspaceSyncer interface {
	SyncWorkspaceProxy(ctx context.Context, workspaceID uint) error
}

WorkspaceSyncer re-renders a workspace's complete proxy config (its routes and middlewares) into the gateway. The route service implements it; middlewares are written as part of that workspace re-render rather than on their own, so a route always sees the up-to-date definition of any middleware it references.

Jump to

Keyboard shortcuts

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