context

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FastlyVclNameRecv    = "vcl_recv"
	FastlyVclNameHash    = "vcl_hash"
	FastlyVclNameHit     = "vcl_hit"
	FastlyVclNameMiss    = "vcl_miss"
	FastlyVclNamePass    = "vcl_pass"
	FastlyVclNameFetch   = "vcl_fetch"
	FastlyVclNameError   = "vcl_error"
	FastlyVclNameDeliver = "vcl_deliver"
	FastlyVclNameLog     = "vcl_log"
)

Reserved vcl names in Fastly

Variables

View Source
var FastlyReservedSubroutine = map[string]string{
	FastlyVclNameRecv:    "recv",
	FastlyVclNameHash:    "hash",
	FastlyVclNameHit:     "hit",
	FastlyVclNameMiss:    "miss",
	FastlyVclNamePass:    "pass",
	FastlyVclNameFetch:   "fetch",
	FastlyVclNameError:   "error",
	FastlyVclNameDeliver: "deliver",
	FastlyVclNameLog:     "log",
}

Functions

This section is empty.

Types

type Context

type Context struct {
	Resolver            resolver.Resolver
	FastlySnippets      *snippets.Snippets
	Acls                map[string]*value.Acl
	Backends            map[string]*value.Backend
	Tables              map[string]*ast.TableDeclaration
	Subroutines         map[string]*ast.SubroutineDeclaration
	Penaltyboxes        map[string]*ast.PenaltyboxDeclaration
	Ratecounters        map[string]*ast.RatecounterDeclaration
	Gotos               map[string]*ast.GotoStatement
	SubroutineFunctions map[string]*ast.SubroutineDeclaration
	OriginalHost        string

	OverrideMaxBackends int
	OverrideMaxAcls     int
	OverrideRequest     *config.RequestConfig
	OverrideBackends    map[string]*config.OverrideBackend

	Request          *http.Request
	BackendRequest   *http.Request
	BackendResponse  *http.Response
	Object           *http.Response
	Response         *http.Response
	Scope            Scope
	RequestEndTime   time.Time
	RequestStartTime time.Time
	CacheHitItem     *cache.CacheItem

	// Interpreter states, following variables could be set in each subroutine directives
	Restarts                            int
	State                               string
	RequestHash                         *value.String
	Backend                             *value.Backend
	MaxStaleIfError                     *value.RTime
	MaxStaleWhileRevalidate             *value.RTime
	Stale                               *value.Boolean
	StaleIsError                        *value.Boolean
	StaleIsRevalidating                 *value.Boolean
	StaleContents                       *value.String
	FastlyError                         *value.String
	ClientIdentity                      *value.String
	ClientGeoIpOverride                 *value.String
	ClientSocketCongestionAlgorithm     *value.String
	ClientSocketCwnd                    *value.Integer
	ClientSocketPace                    *value.Integer
	EsiAllowInsideCData                 *value.Boolean
	EnableRangeOnPass                   *value.Boolean
	EnableSegmentedCaching              *value.Boolean
	EnableSSI                           *value.Boolean
	HashAlwaysMiss                      *value.Boolean
	HashIgnoreBusy                      *value.Boolean
	SegmentedCacheingBlockSize          *value.Integer
	ESILevel                            *value.Integer
	WafAnomalyScore                     *value.Integer
	WafBlocked                          *value.Boolean
	WafCounter                          *value.Integer
	WafExecuted                         *value.Boolean
	WafHttpViolationScore               *value.Integer
	WafInbouldAnomalyScore              *value.Integer
	WafLFIScore                         *value.Integer
	WafLogData                          *value.String
	WafLogged                           *value.Boolean
	WafMessage                          *value.String
	WafPassed                           *value.Boolean
	WafRFIScore                         *value.Integer
	WafRuleId                           *value.Integer
	WafSesionFixationScore              *value.Integer
	WafSeverity                         *value.Integer
	WafXSSScore                         *value.Integer
	BetweenBytesTimeout                 *value.RTime
	ConnectTimeout                      *value.RTime
	FirstByteTimeout                    *value.RTime
	BackendResponseGzip                 *value.Boolean
	BackendResponseBrotli               *value.Boolean
	BackendResponseCacheable            *value.Boolean
	BackendResponseDoESI                *value.Boolean
	BackendResponseDoStream             *value.Boolean
	BackendResponseGrace                *value.RTime
	BackendResponseHipaa                *value.Boolean
	BackendResponsePCI                  *value.Boolean
	BackendResponseResponse             *value.String
	BackendResponseSaintMode            *value.RTime
	BackendResponseStaleIfError         *value.RTime
	BackendResponseStaleWhileRevalidate *value.RTime
	BackendResponseStatus               *value.Integer
	BackendResponseTTL                  *value.RTime
	ObjectGrace                         *value.RTime
	ObjectTTL                           *value.RTime
	ObjectStatus                        *value.Integer
	ObjectResponse                      *value.String
	IsLocallyGenerated                  *value.Boolean

	// For testing fields
	// Stored subroutine return state
	ReturnState     *value.String
	FixedTime       *time.Time
	SubroutineCalls map[string]int

	// Regex captured values like "re.group.N" and local declared variables are volatile,
	// reset this when process is outgoing for each subroutines
	RegexMatchedValues map[string]*value.String

	// Modify states from builtin functions
	DisableCompressionHeaders []string // modified via "h2.disable_header_compression"
	PushResources             []string // modified via "h2.push"
	H3AltSvc                  bool     // modified via "h3.alt_svc"

	// Marker that ESI is triggered. This field will be changed when esi statement is present.
	// However, Fastly document says the esi will be triggered when esi statement is executed in FETCH directive.
	// see: https://developer.fastly.com/reference/vcl/statements/esi/
	TriggerESI bool
}

func New

func New(options ...Option) *Context

type Option

type Option func(c *Context)

func WithMaxAcls

func WithMaxAcls(max int) Option

func WithMaxBackends

func WithMaxBackends(max int) Option

func WithOverrideBackends

func WithOverrideBackends(ov map[string]*config.OverrideBackend) Option

func WithOverrideHost

func WithOverrideHost(host string) Option

func WithRequest

func WithRequest(r *config.RequestConfig) Option

func WithResolver

func WithResolver(rslv resolver.Resolver) Option

func WithSnippets

func WithSnippets(fs *snippets.Snippets) Option

type Scope

type Scope int
const (
	UnknownScope Scope = 0x0000000000
	InitScope    Scope = 0x0000000001
	RecvScope    Scope = 0x0000000010
	HashScope    Scope = 0x0000000100
	HitScope     Scope = 0x0000001000
	MissScope    Scope = 0x0000010000
	PassScope    Scope = 0x0000100000
	FetchScope   Scope = 0x0001000000
	ErrorScope   Scope = 0x0010000000
	DeliverScope Scope = 0x0100000000
	LogScope     Scope = 0x1000000000
	AnyScope     Scope = 0x1111111111
)

func ScopeByString

func ScopeByString(s string) Scope

func (Scope) Is

func (s Scope) Is(scopes ...Scope) bool

func (Scope) String

func (s Scope) String() string

Jump to

Keyboard shortcuts

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