Documentation ¶
Index ¶
- Constants
- Variables
- func NewContext(contextType context_type.ContextType, value string) context.Context
- func RegisterBuilder(opts context.BuildOptions, registrar ContextBuilderRegistrar) error
- func RegisterParseFunc(opts parseFuncBuildOptions, parserFunc map[context_type.ContextType]parseFunc) error
- type BasicContext
- func (b *BasicContext) Child(idx int) context.Context
- func (b *BasicContext) Clone() context.Context
- func (b *BasicContext) ConfigLines(isDumping bool) ([]string, error)
- func (b *BasicContext) Error() error
- func (b *BasicContext) Father() context.Context
- func (b *BasicContext) HasChild() bool
- func (b *BasicContext) Insert(ctx context.Context, idx int) context.Context
- func (b *BasicContext) Len() int
- func (b *BasicContext) Modify(ctx context.Context, idx int) context.Context
- func (b *BasicContext) QueryAllByKeyWords(kw context.KeyWords) []context.Pos
- func (b *BasicContext) QueryByKeyWords(kw context.KeyWords) context.Pos
- func (b *BasicContext) Remove(idx int) context.Context
- func (b *BasicContext) SetFather(ctx context.Context) error
- func (b *BasicContext) SetValue(v string) error
- func (b *BasicContext) Type() context_type.ContextType
- func (b *BasicContext) Value() string
- type BuildBasicContextConfig
- type Comment
- func (c *Comment) Child(idx int) context.Context
- func (c *Comment) Clone() context.Context
- func (c *Comment) ConfigLines(isDumping bool) ([]string, error)
- func (c *Comment) Error() error
- func (c *Comment) Father() context.Context
- func (c *Comment) HasChild() bool
- func (c *Comment) Insert(ctx context.Context, idx int) context.Context
- func (c *Comment) Len() int
- func (c *Comment) MarshalJSON() ([]byte, error)
- func (c *Comment) Modify(ctx context.Context, idx int) context.Context
- func (c *Comment) QueryAllByKeyWords(kw context.KeyWords) []context.Pos
- func (c *Comment) QueryByKeyWords(kw context.KeyWords) context.Pos
- func (c *Comment) Remove(idx int) context.Context
- func (c *Comment) SetFather(ctx context.Context) error
- func (c *Comment) SetValue(v string) error
- func (c *Comment) Type() context_type.ContextType
- func (c *Comment) Value() string
- type Config
- type ConfigGraph
- type ContextBuilderRegistrar
- type Directive
- func (d *Directive) Child(idx int) context.Context
- func (d *Directive) Clone() context.Context
- func (d *Directive) ConfigLines(isDumping bool) ([]string, error)
- func (d *Directive) Error() error
- func (d *Directive) Father() context.Context
- func (d *Directive) HasChild() bool
- func (d *Directive) Insert(ctx context.Context, idx int) context.Context
- func (d *Directive) Len() int
- func (d *Directive) MarshalJSON() ([]byte, error)
- func (d *Directive) Modify(ctx context.Context, idx int) context.Context
- func (d *Directive) QueryAllByKeyWords(kw context.KeyWords) []context.Pos
- func (d *Directive) QueryByKeyWords(kw context.KeyWords) context.Pos
- func (d *Directive) Remove(idx int) context.Context
- func (d *Directive) SetFather(ctx context.Context) error
- func (d *Directive) SetValue(v string) error
- func (d *Directive) Type() context_type.ContextType
- func (d *Directive) Value() string
- type Include
- func (i *Include) Child(idx int) context.Context
- func (i *Include) ChildConfig(fullpath string) (*Config, error)
- func (i *Include) Clone() context.Context
- func (i *Include) ConfigLines(isDumping bool) ([]string, error)
- func (i *Include) Error() error
- func (i *Include) Father() context.Context
- func (i *Include) FatherConfig() (*Config, error)
- func (i *Include) HasChild() bool
- func (i *Include) Insert(ctx context.Context, idx int) context.Context
- func (i *Include) InsertConfig(configs ...*Config) error
- func (i *Include) Len() int
- func (i *Include) MarshalJSON() ([]byte, error)
- func (i *Include) Modify(ctx context.Context, idx int) context.Context
- func (i *Include) ModifyConfig(configs ...*Config) error
- func (i *Include) QueryAllByKeyWords(kw context.KeyWords) []context.Pos
- func (i *Include) QueryByKeyWords(kw context.KeyWords) context.Pos
- func (i *Include) Remove(idx int) context.Context
- func (i *Include) RemoveConfig(configs ...*Config) error
- func (i *Include) SetFather(ctx context.Context) error
- func (i *Include) SetValue(v string) error
- func (i *Include) Type() context_type.ContextType
- func (i *Include) Value() string
- type Loader
- type Main
- func (m *Main) Child(idx int) context.Context
- func (m *Main) Clone() context.Context
- func (m *Main) ConfigLines(isDumping bool) ([]string, error)
- func (m *Main) Error() error
- func (m *Main) Father() context.Context
- func (m *Main) HasChild() bool
- func (m *Main) Insert(ctx context.Context, idx int) context.Context
- func (m *Main) Len() int
- func (m *Main) MarshalJSON() ([]byte, error)
- func (m *Main) Modify(ctx context.Context, idx int) context.Context
- func (m *Main) QueryAllByKeyWords(kw context.KeyWords) []context.Pos
- func (m *Main) QueryByKeyWords(kw context.KeyWords) context.Pos
- func (m *Main) Remove(idx int) context.Context
- func (m *Main) SetFather(ctx context.Context) error
- func (m *Main) SetValue(v string) error
- func (m *Main) Type() context_type.ContextType
- func (m *Main) Value() string
- type MainContext
Constants ¶
View Source
const ( DoubleQuotes = `\s*"[^"]*"` SingleQuotes = `\s*'[^']*'` Normal = `\s*[^;\s#]+` Abnormal = `^[\n\r\t\f ]*;.*` LineBreak = `[\n\r]` S1 = DoubleQuotes + `|` + SingleQuotes + `|` + Normal S = `^\s*(` + S1 + `)\s+((?:` + S1 + `)+)\s*;` )
View Source
const INDENT = " "
Variables ¶
View Source
var ( // regexps RegCommentHead = regexp.MustCompile(`^(\s*)#+[ \t\f]*([^\r\n]*?)` + LineBreak + `+`) RegDirectiveWithValue = regexp.MustCompile(S) RegDirectiveWithoutValue = regexp.MustCompile(`^\s*(` + Normal + `)\s*;`) RegEventsHead = regexp.MustCompile(`^\s*events\s*{`) RegGeoHead = regexp.MustCompile(`^\s*geo\s*([^;]*?)\s*{`) RegHttpHead = regexp.MustCompile(`^\s*http\s*{`) RegIfHead = regexp.MustCompile(`^\s*if\s*([^;]*?)\s*{`) RegLimitExceptHead = regexp.MustCompile(`^\s*limit_except\s*([^;]*?)\s*{`) RegLocationHead = regexp.MustCompile(`^\s*location\s*([^;]*?)\s*{`) RegMapHead = regexp.MustCompile(`^\s*map\s*([^;]*?)\s*{`) RegServerHead = regexp.MustCompile(`^\s*server\s*{`) RegStreamHead = regexp.MustCompile(`^\s*stream\s*{`) RegTypesHead = regexp.MustCompile(`^\s*types\s*{`) RegUpstreamHead = regexp.MustCompile(`^\s*upstream\s*([^;]*?)\s*{`) RegBlankLine = regexp.MustCompile(`^` + LineBreak + `\s*` + LineBreak + `$`) RegBraceEnd = regexp.MustCompile(`^\s*}`) RegErrorHeed = regexp.MustCompile(Abnormal) RegLineBreak = regexp.MustCompile(LineBreak) // json unmarshal regexps JsonUnmarshalRegCommentHead = regexp.MustCompile(`^\s*{[^{]*"comments"\s*:\s*"`) JsonUnmarshalRegEventsHead = regexp.MustCompile(`^\s*{\s*"events"\s*:\s*{`) JsonUnmarshalRegGeoHead = regexp.MustCompile(`^\s*{\s*"geo"\s*:\s*{`) JsonUnmarshalRegHttpHead = regexp.MustCompile(`^\s*{\s*"http"\s*:\s*{`) JsonUnmarshalRegIfHead = regexp.MustCompile(`^\s*{\s*"if"\s*:\s*{`) JsonUnmarshalRegIncludeHead = regexp.MustCompile(`^\s*{\s*"include"\s*:\s*{`) JsonUnmarshalRegLimitExceptHead = regexp.MustCompile(`^\s*{\s*"limit_except"\s*:\s*{`) JsonUnmarshalRegLocationHead = regexp.MustCompile(`^\s*{\s*"location"\s*:\s*{`) JsonUnmarshalRegMapHead = regexp.MustCompile(`^\s*{\s*"map"\s*:\s*{`) JsonUnmarshalRegServerHead = regexp.MustCompile(`^\s*{\s*"server"\s*:\s*{`) JsonUnmarshalRegStreamHead = regexp.MustCompile(`^\s*{\s*"stream"\s*:\s*{`) JsonUnmarshalRegTypesHead = regexp.MustCompile(`^\s*{\s*"types"\s*:\s*{`) JsonUnmarshalRegUpstreamHead = regexp.MustCompile(`^\s*{\s*"upstream"\s*:\s*{`) )
Functions ¶
func NewContext ¶
func NewContext(contextType context_type.ContextType, value string) context.Context
func RegisterBuilder ¶
func RegisterBuilder(opts context.BuildOptions, registrar ContextBuilderRegistrar) error
func RegisterParseFunc ¶
func RegisterParseFunc(opts parseFuncBuildOptions, parserFunc map[context_type.ContextType]parseFunc) error
Types ¶
type BasicContext ¶
type BasicContext struct { ContextType context_type.ContextType `json:"context-type"` ContextValue string `json:"value,omitempty"` Children []context.Context `json:"params,omitempty"` // contains filtered or unexported fields }
func (*BasicContext) Clone ¶
func (b *BasicContext) Clone() context.Context
func (*BasicContext) ConfigLines ¶
func (b *BasicContext) ConfigLines(isDumping bool) ([]string, error)
func (*BasicContext) Error ¶
func (b *BasicContext) Error() error
func (*BasicContext) Father ¶
func (b *BasicContext) Father() context.Context
func (*BasicContext) HasChild ¶
func (b *BasicContext) HasChild() bool
func (*BasicContext) Len ¶
func (b *BasicContext) Len() int
func (*BasicContext) QueryAllByKeyWords ¶
func (b *BasicContext) QueryAllByKeyWords(kw context.KeyWords) []context.Pos
func (*BasicContext) QueryByKeyWords ¶
func (b *BasicContext) QueryByKeyWords(kw context.KeyWords) context.Pos
func (*BasicContext) SetValue ¶
func (b *BasicContext) SetValue(v string) error
func (*BasicContext) Type ¶
func (b *BasicContext) Type() context_type.ContextType
func (*BasicContext) Value ¶
func (b *BasicContext) Value() string
type BuildBasicContextConfig ¶
type BuildBasicContextConfig struct { ContextType context_type.ContextType // contains filtered or unexported fields }
func OptsApplyTo ¶
func OptsApplyTo(opts context.BuildOptions) (BuildBasicContextConfig, error)
func (BuildBasicContextConfig) BasicContext ¶
func (b BuildBasicContextConfig) BasicContext() *BasicContext
type Comment ¶
func (*Comment) MarshalJSON ¶ added in v1.0.12
func (*Comment) QueryAllByKeyWords ¶
func (*Comment) QueryByKeyWords ¶
func (*Comment) Type ¶
func (c *Comment) Type() context_type.ContextType
type Config ¶
type Config struct { BasicContext context.ConfigPath `json:"-"` }
type ConfigGraph ¶
type ContextBuilderRegistrar ¶
type ContextBuilderRegistrar func(func() *BasicContext) func(value string) context.Context
type Directive ¶
func (*Directive) MarshalJSON ¶ added in v1.0.12
func (*Directive) QueryAllByKeyWords ¶
func (*Directive) QueryByKeyWords ¶
func (*Directive) Type ¶
func (d *Directive) Type() context_type.ContextType
type Include ¶
type Include struct { ContextValue string Configs map[string]*Config // contains filtered or unexported fields }
func (*Include) FatherConfig ¶
func (*Include) InsertConfig ¶
func (*Include) MarshalJSON ¶
func (*Include) ModifyConfig ¶
func (*Include) QueryAllByKeyWords ¶
func (*Include) QueryByKeyWords ¶
func (*Include) RemoveConfig ¶
func (*Include) Type ¶
func (i *Include) Type() context_type.ContextType
type Loader ¶
type Loader interface {
Load() (MainContext, error)
}
func FileLoader ¶
func JsonLoader ¶
type Main ¶
type Main struct {
ConfigGraph
}
func (*Main) MarshalJSON ¶
func (*Main) QueryAllByKeyWords ¶
func (*Main) Type ¶
func (m *Main) Type() context_type.ContextType
type MainContext ¶
type MainContext interface { context.Context ConfigGraph // contains filtered or unexported methods }
func NewMain ¶
func NewMain(abspath string) (MainContext, error)
Click to show internal directories.
Click to hide internal directories.