plugins: github.com/goadesign/plugins/cors/expr Index | Files

package expr

import "github.com/goadesign/plugins/cors/expr"

Index

Package Files

cors.go root.go

Variables

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

Root is the design root expression.

func PreflightPaths Uses

func PreflightPaths(svc string) []string

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

type OriginExpr Uses

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 Uses

func Origins(svc string) []*OriginExpr

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

func (*OriginExpr) EvalName Uses

func (o *OriginExpr) EvalName() string

EvalName returns the generic expression name used in error messages.

func (*OriginExpr) Validate Uses

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

Validate ensures the origin expression is valid.

type RootExpr Uses

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]map[string]*OriginExpr
}

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

func (*RootExpr) DependsOn Uses

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

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

func (*RootExpr) EvalName Uses

func (r *RootExpr) EvalName() string

EvalName returns the name used in error messages.

func (*RootExpr) Packages Uses

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 Uses

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

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

Package expr imports 6 packages (graph). Updated 2019-06-30. Refresh now. Tools for package owners.