expr

package
v2.2.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Root = &RootExpr{
	APIOrigins:     map[string]*OriginExpr{},
	ServiceOrigins: map[string]*OriginExpr{},
}

Root is the design root expression.

Functions

func PreflightPaths

func PreflightPaths(svc string) []string

PreflightPaths returns the paths that should handle OPTIONS requests for the given service.

Types

type OriginExpr

type OriginExpr struct {
	// Origin is the origin string.
	Origin string
	// Methods is the list of authorized HTTP methods.
	Methods []string
	// Exposed is the list of headers exposed to clients.
	Exposed []string
	// Headers is the list of authorized headers, "*" authorizes all.
	Headers []string
	// MaxAge is the duration to cache a preflight request response.
	MaxAge uint
	// Credentials sets Access-Control-Allow-Credentials header in the
	// response.
	Credentials bool
	// Regexp tells whether the Origin string is a regular expression.
	Regexp bool
	// Parent expression, ServiceExpr or APIExpr.
	Parent eval.Expression
}

OriginExpr describes a CORS policy.

func Origins

func Origins(svc string) []*OriginExpr

Origins returns the origin expressions (sorted alphabetically by origin string) for the given service.

func (*OriginExpr) EvalName

func (o *OriginExpr) EvalName() string

EvalName returns the generic expression name used in error messages.

func (*OriginExpr) Validate

func (o *OriginExpr) Validate() *eval.ValidationErrors

Validate ensures the origin expression is valid.

type RootExpr

type RootExpr struct {
	// APIOrigins lists all the CORS definitions indexed by origin string
	// at the API level.
	APIOrigins map[string]*OriginExpr
	// ServiceOrigins lists all the CORS definitions indexed by origin string
	// at the service level.
	ServiceOrigins map[string]*OriginExpr
}

RootExpr keeps track of the CORS origins defined in the design.

func (*RootExpr) DependsOn

func (r *RootExpr) DependsOn() []eval.Root

DependsOn tells the eval engine to run the goa DSL first.

func (*RootExpr) EvalName

func (r *RootExpr) EvalName() string

EvalName returns the name used in error messages.

func (*RootExpr) Packages

func (r *RootExpr) Packages() []string

Packages returns the import path to the Go packages that make up the DSL. This is used to skip frames that point to files in these packages when computing the location of errors.

func (*RootExpr) WalkSets

func (r *RootExpr) WalkSets(walk eval.SetWalker)

WalkSets iterates over the API-level and service-level CORS definitions.

Jump to

Keyboard shortcuts

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