loader

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DoubleQuotes = `\s*"[^"]*"`
	SingleQuotes = `\s*'[^']*'`
	Normal       = `\s*[^;\s]+`
	Abnormal     = `^[\t\f ]*;.*`
	LineBreak    = `\n`
	S1           = DoubleQuotes + `|` + SingleQuotes + `|` + Normal
	S            = `^\s*(` + S1 + `)\s+((?:` + S1 + `)+)\s*;`
)

Variables

View Source
var (

	// regexp
	// RegEndWithCR       = regexp.MustCompile("}\n+$").
	RegEventsHead      = regexp.MustCompile(`^\s*events\s*{`)
	RegHttpHead        = regexp.MustCompile(`^\s*http\s*{`)
	RegStreamHead      = regexp.MustCompile(`^\s*stream\s*{`)
	RegServerHead      = regexp.MustCompile(`^\s*server\s*{`)
	RegLocationHead    = regexp.MustCompile(`^\s*location\s*([^;]*?)\s*{`)
	RegIfHead          = regexp.MustCompile(`^\s*if\s*([^;]*?)\s*{`)
	RegUpstreamHead    = regexp.MustCompile(`^\s*upstream\s*([^;]*?)\s*{`)
	RegGeoHead         = regexp.MustCompile(`^\s*geo\s*([^;]*?)\s*{`)
	RegMapHead         = regexp.MustCompile(`^\s*map\s*([^;]*?)\s*{`)
	RegLimitExceptHead = regexp.MustCompile(`^\s*limit_except\s*([^;]*?)\s*{`)
	RegTypesHead       = regexp.MustCompile(`^\s*types\s*{`)
	RegContextEnd      = regexp.MustCompile(`^\s*}`)
	RegCommentHead     = regexp.MustCompile(`^(\s*)#+[ \r\t\f]*(.*?)\n`)
	RegKeyValue        = regexp.MustCompile(S)
	RegKey             = regexp.MustCompile(`^\s*(` + Normal + `)\s*;`)
	RegBlankLine       = regexp.MustCompile(`^\n\s*` + LineBreak + `$`)
	RegErrorHeed       = regexp.MustCompile(Abnormal)

	JsonUnmarshalRegEventsHead      = regexp.MustCompile(`^\s*{\s*"events"\s*:\s*{`)
	JsonUnmarshalRegHttpHead        = regexp.MustCompile(`^\s*{\s*"http"\s*:\s*{`)
	JsonUnmarshalRegStreamHead      = regexp.MustCompile(`^\s*{\s*"stream"\s*:\s*{`)
	JsonUnmarshalRegServerHead      = regexp.MustCompile(`^\s*{\s*"server"\s*:\s*{`)
	JsonUnmarshalRegLocationHead    = regexp.MustCompile(`^\s*{\s*"location"\s*:\s*{`)
	JsonUnmarshalRegIfHead          = regexp.MustCompile(`^\s*{\s*"if"\s*:\s*{`)
	JsonUnmarshalRegUpstreamHead    = regexp.MustCompile(`^\s*{\s*"upstream"\s*:\s*{`)
	JsonUnmarshalRegGeoHead         = regexp.MustCompile(`^\s*{\s*"geo"\s*:\s*{`)
	JsonUnmarshalRegMapHead         = regexp.MustCompile(`^\s*{\s*"map"\s*:\s*{`)
	JsonUnmarshalRegLimitExceptHead = regexp.MustCompile(`^\s*{\s*"limit_except"\s*:\s*{`)
	JsonUnmarshalRegTypesHead       = regexp.MustCompile(`^\s*{\s*"types"\s*:\s*{`)
	JsonUnmarshalRegIncludeHead     = regexp.MustCompile(`^\s*{\s*"include"\s*:\s*{`)
	JsonUnmarshalRegConfigHead      = regexp.MustCompile(`^\s*{\s*"config"\s*:\s*{`)
	JsonUnmarshalRegCommentHead     = regexp.MustCompile(`^\s*{\s*"comments"\s*:\s*"`)
)

Functions

func NewUnmarshaler

func NewUnmarshaler() *unmarshaler

Types

type LoadCacher

type LoadCacher interface {
	MainConfig() *parser.Config
	GetConfig(configName string) *parser.Config
	Keys() []string
	// CheckIncludeConfig(src, dst string) error
	SetConfig(config *parser.Config) error
}

func NewLoadCacher

func NewLoadCacher(configAbsPath string) LoadCacher

type Loader

type Loader interface {
	LoadFromFilePath(path string) (parser.Context, loop_preventer.LoopPreventer, error)
	LoadFromJsonBytes(data []byte) (parser.Context, loop_preventer.LoopPreventer, error)
	GetConfigPaths() []string
}

func NewLoader

func NewLoader() Loader

type UnmarshalContext

type UnmarshalContext interface {
	GetValue() string
	GetChildren() []*json.RawMessage
}

Jump to

Keyboard shortcuts

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