Documentation
¶
Overview ¶
Package middleware manages Goma Gateway middlewares owned by workspaces and reconciles them into the proxy provider.
Index ¶
- Variables
- type Input
- type Service
- func (s *Service) Create(ctx context.Context, workspaceID uint, in Input) (*models.Middleware, error)
- func (s *Service) Delete(ctx context.Context, workspaceID, id uint) error
- func (s *Service) Get(workspaceID, id uint) (*models.Middleware, error)
- func (s *Service) List(workspaceID uint) ([]models.Middleware, error)
- func (s *Service) SeedDefaults(ctx context.Context, workspaceID uint) error
- func (s *Service) Update(ctx context.Context, workspaceID, id uint, in Input) (*models.Middleware, error)
- type WorkspaceSyncer
Constants ¶
This section is empty.
Variables ¶
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 Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(repo *repositories.MiddlewareRepository, syncer WorkspaceSyncer) *Service
func (*Service) SeedDefaults ¶ added in v1.5.0
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.
type WorkspaceSyncer ¶
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.