middleware

package
v1.44.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidTargetForService = errRange.Newf(
		"Invalid middleware target",
		"There are not matching targets in service %q.",
	)

	ErrInvalidTargetForApp = errRange.New(
		"Invalid middleware target",
		"There are not matching targets in the application.",
	)

	ErrSvcMiddlewareNotInService = errRange.New(
		"Invalid middleware function",
		"Middleware must be defined in a service unless it is marked as being global.",
	)

	ErrGlobalMiddlewareDefinedInService = errRange.New(
		"Invalid middleware function",
		"Global middleware cannot be defined in a service.",
	)
)

Functions

func Sort

func Sort(mws []*Middleware)

Sort sorts the middleware to ensure they execute in deterministic order.

Types

type Middleware

type Middleware struct {
	Decl *schema.FuncDecl
	Doc  string
	File *pkginfo.File // file it's declared in

	// Global specifies whether the middleware is global or service-local.
	Global bool

	// Target specifies the set of API endpoints the middleware applies to.
	Target selector.Set

	// Recv is the type the middleware is defined as a method on, if any.
	Recv option.Option[*schema.Receiver]
}

Middleware describes an Encore middleware.

func Parse

func Parse(d ParseData) *Middleware

Parse parses the middleware in the provided declaration. It may return nil on errors.

func (*Middleware) End

func (mw *Middleware) End() token.Pos

func (*Middleware) ID added in v1.16.0

func (mw *Middleware) ID() string

ID returns a unique id for this specific middleware.

func (*Middleware) Kind

func (mw *Middleware) Kind() resource.Kind

func (*Middleware) Package

func (mw *Middleware) Package() *pkginfo.Package

func (*Middleware) Pos

func (mw *Middleware) Pos() token.Pos

func (*Middleware) SortKey added in v1.16.3

func (mw *Middleware) SortKey() string

type ParseData

type ParseData struct {
	Errs   *perr.List
	Schema *schema.Parser

	File *pkginfo.File
	Func *ast.FuncDecl
	Dir  *directive.Directive
	Doc  string
}

Jump to

Keyboard shortcuts

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