config

package
v0.0.0-...-77fca55 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidDirective = errors.New("entry is not a directive")

Functions

This section is empty.

Types

type Block

type Block struct {
	Comments []Comment
	// contains filtered or unexported fields
}

func (*Block) AddDirective

func (b *Block) AddDirective(directive Directive, begining bool)

func (*Block) DeleteDirective

func (b *Block) DeleteDirective(directive Directive)

func (*Block) DeleteDirectiveByName

func (b *Block) DeleteDirectiveByName(directiveName string)

func (*Block) FindBlocks

func (b *Block) FindBlocks(blockName string) []Block

func (*Block) FindDirectives

func (b *Block) FindDirectives(directiveName string) []Directive

func (*Block) GetName

func (b *Block) GetName() string

func (*Block) GetParameters

func (b *Block) GetParameters() []string

func (*Block) SetParameters

func (b *Block) SetParameters(parameters []string)

type Comment

type Comment struct {
	Content  string
	Position CommentPosition
	// contains filtered or unexported fields
}

type CommentPosition

type CommentPosition int
const (
	Inline CommentPosition = iota
	Before
)

type Config

type Config struct {
	// contains filtered or unexported fields
}

func GetConfig

func GetConfig(serverRootPath, configFilePath string, quiteMode bool) (*Config, error)

func (*Config) AddConfigFile

func (c *Config) AddConfigFile(filePath string) (*ConfigFile, error)

func (*Config) Dump

func (c *Config) Dump() error

func (*Config) FindBlocks

func (c *Config) FindBlocks(blockName string) []Block

func (*Config) FindDirectives

func (c *Config) FindDirectives(directiveName string) []Directive

func (*Config) FindHttpBlocks

func (c *Config) FindHttpBlocks() []HttpBlock

func (*Config) FindLocationBlocks

func (c *Config) FindLocationBlocks() []LocationBlock

func (*Config) FindServerBlocks

func (c *Config) FindServerBlocks() []ServerBlock

func (*Config) FindServerBlocksByServerName

func (c *Config) FindServerBlocksByServerName(serverName string) []ServerBlock

func (*Config) FindUpstreamBlocks

func (c *Config) FindUpstreamBlocks() []UpstreamBlock

func (*Config) FindUpstreamBlocksByName

func (c *Config) FindUpstreamBlocksByName(upstreamName string) []UpstreamBlock

func (*Config) GetConfigFile

func (c *Config) GetConfigFile(configFileName string) *ConfigFile

type ConfigFile

type ConfigFile struct {
	FilePath string
	// contains filtered or unexported fields
}

func (*ConfigFile) AddDirective

func (c *ConfigFile) AddDirective(directive Directive, begining bool)

func (*ConfigFile) AddHttpBlock

func (c *ConfigFile) AddHttpBlock() HttpBlock

func (*ConfigFile) DeleteDirective

func (c *ConfigFile) DeleteDirective(directive Directive)

func (*ConfigFile) DeleteDirectiveByName

func (c *ConfigFile) DeleteDirectiveByName(directiveName string)

func (*ConfigFile) DeleteHttpBlock

func (c *ConfigFile) DeleteHttpBlock(httpBlock HttpBlock)

func (*ConfigFile) DeleteServerBlock

func (c *ConfigFile) DeleteServerBlock(serverBlock ServerBlock)

func (*ConfigFile) DeleteUpstreamBlock

func (c *ConfigFile) DeleteUpstreamBlock(upstreamBlock ServerBlock)

func (*ConfigFile) Dump

func (c *ConfigFile) Dump() error

func (*ConfigFile) FindBlocks

func (c *ConfigFile) FindBlocks(blockName string) []Block

func (*ConfigFile) FindDirectives

func (c *ConfigFile) FindDirectives(directiveName string) []Directive

func (*ConfigFile) FindHttpBlocks

func (c *ConfigFile) FindHttpBlocks() []HttpBlock

func (*ConfigFile) FindServerBlocks

func (c *ConfigFile) FindServerBlocks() []ServerBlock

func (*ConfigFile) FindServerBlocksByServerName

func (c *ConfigFile) FindServerBlocksByServerName(serverName string) []ServerBlock

func (*ConfigFile) FindUpstreamBlocks

func (c *ConfigFile) FindUpstreamBlocks() []UpstreamBlock

func (*ConfigFile) FindUpstreamBlocksByName

func (c *ConfigFile) FindUpstreamBlocksByName(upstreamName string) []UpstreamBlock

type Directive

type Directive struct {
	Comments []Comment
	// contains filtered or unexported fields
}

func NewDirective

func NewDirective(name string, values []string) Directive

func (*Directive) AddValue

func (d *Directive) AddValue(expression string)

func (*Directive) GetFirstValue

func (d *Directive) GetFirstValue() string

func (*Directive) GetName

func (d *Directive) GetName() string

func (*Directive) GetValues

func (d *Directive) GetValues() []string

func (*Directive) SetValue

func (d *Directive) SetValue(expression string)

func (*Directive) SetValues

func (d *Directive) SetValues(expressions []string)

type HttpBlock

type HttpBlock struct {
	Block
}

func (*HttpBlock) AddServerBlock

func (b *HttpBlock) AddServerBlock() ServerBlock

func (*HttpBlock) AddUpstreamBlock

func (b *HttpBlock) AddUpstreamBlock(upstreamName string) UpstreamBlock

func (*HttpBlock) DeleteServerBlock

func (b *HttpBlock) DeleteServerBlock(serverBlock ServerBlock)

func (*HttpBlock) DeleteUpstreamBlock

func (b *HttpBlock) DeleteUpstreamBlock(upsstreamBlock UpstreamBlock)

func (*HttpBlock) FindBlocks

func (b *HttpBlock) FindBlocks(blockName string) []Block

func (*HttpBlock) FindLocationBlocks

func (b *HttpBlock) FindLocationBlocks() []LocationBlock

func (*HttpBlock) FindServerBlocks

func (b *HttpBlock) FindServerBlocks() []ServerBlock

func (*HttpBlock) FindServerBlocksByServerName

func (b *HttpBlock) FindServerBlocksByServerName(serverName string) []ServerBlock

func (*HttpBlock) FindUpstreamBlocks

func (b *HttpBlock) FindUpstreamBlocks() []UpstreamBlock

func (*HttpBlock) FindUpstreamBlocksByName

func (b *HttpBlock) FindUpstreamBlocksByName(upstreamName string) []UpstreamBlock

type Listen

type Listen struct {
	HostPort string
	Ssl      bool
	Ipv6only bool
}

type LocationBlock

type LocationBlock struct {
	Block
}

func (*LocationBlock) AddLocationBlock

func (l *LocationBlock) AddLocationBlock(modifier, match string) LocationBlock

func (*LocationBlock) DeleteLocationBlock

func (l *LocationBlock) DeleteLocationBlock(locationBlock LocationBlock)

func (*LocationBlock) GetLocationMatch

func (l *LocationBlock) GetLocationMatch() string

func (*LocationBlock) GetModifier

func (l *LocationBlock) GetModifier() string

func (*LocationBlock) SetLocationMatch

func (l *LocationBlock) SetLocationMatch(match string)

func (*LocationBlock) SetModifier

func (l *LocationBlock) SetModifier(modifier string)

type ServerAddress

type ServerAddress struct {
	IsIpv6 bool
	Host   string
	Port   string
}

func CreateServerAddressFromString

func CreateServerAddressFromString(addrStr string) ServerAddress

CreateServerAddressFromString parses address string and returns Address structure

func (ServerAddress) GetAddressWithNewPort

func (a ServerAddress) GetAddressWithNewPort(port string) ServerAddress

GetAddressWithNewPort returns new a ServerAddress instance with changed port

func (ServerAddress) GetHash

func (a ServerAddress) GetHash() string

GetHash returns addr hash based on host an port

func (ServerAddress) GetNormalizedHost

func (a ServerAddress) GetNormalizedHost() string

GetNormalizedHost returns normalized host. Normalization occurres only for ipv6 address. Ipv4 returns as is. For example: [fd00:dead:beaf::1] -> fd00:dead:beaf:0:0:0:0:1

func (ServerAddress) GetNormalizedIpv6

func (a ServerAddress) GetNormalizedIpv6() string

GetNormalizedIpv6 returns normalized IPv6 For example: [fd00:dead:beaf::1] -> fd00:dead:beaf:0:0:0:0:1

func (ServerAddress) IsEqual

func (a ServerAddress) IsEqual(b ServerAddress) bool

func (ServerAddress) IsWildcardPort

func (a ServerAddress) IsWildcardPort() bool

func (ServerAddress) ToString

func (a ServerAddress) ToString() string

type ServerBlock

type ServerBlock struct {
	Block
}

func (*ServerBlock) AddLocationBlock

func (s *ServerBlock) AddLocationBlock(modifier, match string) LocationBlock

func (*ServerBlock) DeleteLocationBlock

func (s *ServerBlock) DeleteLocationBlock(locationBlock LocationBlock)

func (*ServerBlock) FindLocationBlocks

func (s *ServerBlock) FindLocationBlocks() []LocationBlock

func (*ServerBlock) GetAddresses

func (s *ServerBlock) GetAddresses() []ServerAddress

func (*ServerBlock) GetDocumentRoot

func (s *ServerBlock) GetDocumentRoot() string

func (*ServerBlock) GetListens

func (s *ServerBlock) GetListens() []Listen

func (*ServerBlock) GetServerNames

func (s *ServerBlock) GetServerNames() []string

func (*ServerBlock) HasSSL

func (s *ServerBlock) HasSSL() bool

func (*ServerBlock) IsIpv4Enabled

func (s *ServerBlock) IsIpv4Enabled() bool

func (*ServerBlock) IsIpv6Enabled

func (s *ServerBlock) IsIpv6Enabled() bool

type UpstreamBlock

type UpstreamBlock struct {
	Block
}

func (*UpstreamBlock) AddServer

func (b *UpstreamBlock) AddServer(upstreamServer UpstreamServer)

func (*UpstreamBlock) DeleteServer

func (b *UpstreamBlock) DeleteServer(upstreamServer UpstreamServer)

func (*UpstreamBlock) GetServers

func (b *UpstreamBlock) GetServers() []UpstreamServer

func (*UpstreamBlock) GetUpstreamName

func (b *UpstreamBlock) GetUpstreamName() string

func (*UpstreamBlock) SetServers

func (b *UpstreamBlock) SetServers(upstreamServers []UpstreamServer)

func (*UpstreamBlock) SetUpstreamName

func (b *UpstreamBlock) SetUpstreamName(name string)

type UpstreamServer

type UpstreamServer struct {
	Directive
}

func NewUpstreamServer

func NewUpstreamServer(address string, flags []string) UpstreamServer

func (*UpstreamServer) GetAddress

func (s *UpstreamServer) GetAddress() string

func (*UpstreamServer) GetFlags

func (s *UpstreamServer) GetFlags() []string

func (*UpstreamServer) SetAddress

func (s *UpstreamServer) SetAddress(address string)

func (*UpstreamServer) SetFlags

func (s *UpstreamServer) SetFlags(flags []string)

Jump to

Keyboard shortcuts

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