teaconfigs

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2019 License: MIT Imports: 25 Imported by: 40

Documentation

Index

Constants

View Source
const (
	LocationPatternTypePrefix = 1
	LocationPatternTypeExact  = 2
	LocationPatternTypeRegexp = 3
)

内置的匹配类型定义

View Source
const (
	RewriteOperatorRegexp   = "regexp"
	RewriteOperatorGt       = "gt"
	RewriteOperatorGte      = "gte"
	RewriteOperatorLt       = "lt"
	RewriteOperatorLte      = "lte"
	RewriteOperatorEq       = "eq"
	RewriteOperatorNot      = "not"
	RewriteOperatorPrefix   = "prefix"
	RewriteOperatorSuffix   = "suffix"
	RewriteOperatorContains = "contains"
)
View Source
const (
	RewriteTargetProxy = 1
	RewriteTargetURL   = 2
)
View Source
const (
	RewriteFlagRedirect = "r" // 跳转,TODO: 实现 302, 305
	RewriteFlagProxy    = "p" // 代理
)
View Source
const (
	WebsocketForwardModeWebsocket = "websocket"
	WebsocketForwardModeHttp      = "http"
)

Variables

View Source
var RegexpDigitNumber = regexp.MustCompile("^\\d+$")
View Source
var RegexpDigitVariable = regexp.MustCompile("\\${\\d+}")
View Source
var RegexpExternalURL = regexp.MustCompile("(?i)^(http|https|ftp)://")
View Source
var RegexpNamedVariable = regexp.MustCompile("\\${[\\w.-]+}")

Functions

func AllLocationPatternTypes

func AllLocationPatternTypes() []maps.Map

取得所有的匹配类型信息

func AllRewriteOperators

func AllRewriteOperators() []maps.Map

所有的运算符

func AllWebsocketForwardModes

func AllWebsocketForwardModes() []maps.Map

所有的转发方式

func FindLocationPatternType

func FindLocationPatternType(patternType int) maps.Map

查找单个匹配类型信息

func FindLocationPatternTypeName

func FindLocationPatternTypeName(patternType int) string

查找单个匹配类型名称

func FindRewriteOperator

func FindRewriteOperator(op string) maps.Map

查找某个运算符信息

Types

type AccessLogConfig

type AccessLogConfig struct {
	On     bool                   `yaml:"on" json:"on"`
	Target string                 `yaml:"target" json:"target"`
	Config map[string]interface{} `yaml:"config" json:"config"`
}

日志配置 参考 http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log

func (*AccessLogConfig) Validate

func (config *AccessLogConfig) Validate()

type AccessLogFileConfig

type AccessLogFileConfig struct {
	Path   string `yaml:"path"`
	Format string `yaml:"format"`
	Buffer string `yaml:"buffer"` // @TODO
	Flush  string `yaml:"flush"`  // @TODO
}

日志文件配置

type AccessLogPipeConfig

type AccessLogPipeConfig struct {
	Path   string `yaml:"path"`
	Format string `yaml:"format"` // @TODO
	Buffer string `yaml:"buffer"` // @TODO
	Flush  string `yaml:"flush"`  // @TODO
}

日志pipe配置

type AccessLogStdoutConfig

type AccessLogStdoutConfig struct {
	Format string `yaml:"format"`
	Buffer string `yaml:"buffer"` // @TODO
	Flush  string `yaml:"flush"`  // @TODO
}

日志stdout配置

type BackendConfig

type BackendConfig struct {
	shared.HeaderList `yaml:",inline"`

	On           bool      `yaml:"on" json:"on"`                                 // 是否启用
	Id           string    `yaml:"id" json:"id"`                                 // ID
	Code         string    `yaml:"code" json:"code"`                             // 代号
	Name         []string  `yaml:"name" json:"name"`                             // 域名 TODO
	Address      string    `yaml:"address" json:"address"`                       // 地址
	Scheme       string    `yaml:"scheme" json:"scheme"`                         // 协议,http或者https
	Weight       uint      `yaml:"weight" json:"weight"`                         // 权重
	IsBackup     bool      `yaml:"backup" json:"isBackup"`                       // 是否为备份
	FailTimeout  string    `yaml:"failTimeout" json:"failTimeout"`               // 连接失败超时
	ReadTimeout  string    `yaml:"readTimeout" json:"readTimeout"`               // 读取超时时间
	MaxFails     uint      `yaml:"maxFails" json:"maxFails"`                     // 最多失败次数
	CurrentFails uint      `yaml:"currentFails" json:"currentFails"`             // 当前已失败次数
	MaxConns     uint      `yaml:"maxConns" json:"maxConns"`                     // 最大并发连接数
	CurrentConns uint      `yaml:"currentConns" json:"currentConns"`             // 当前连接数
	IsDown       bool      `yaml:"down" json:"isDown"`                           // 是否下线
	DownTime     time.Time `yaml:"downTime,omitempty" json:"downTime,omitempty"` // 下线时间
	// contains filtered or unexported fields
}

服务后端配置

func NewBackendConfig

func NewBackendConfig() *BackendConfig

获取新对象

func (*BackendConfig) CandidateCodes

func (this *BackendConfig) CandidateCodes() []string

候选对象代号

func (*BackendConfig) CandidateWeight

func (this *BackendConfig) CandidateWeight() uint

候选对象权重

func (*BackendConfig) DecreaseConn

func (this *BackendConfig) DecreaseConn()

减少连接数

func (*BackendConfig) FailTimeoutDuration

func (this *BackendConfig) FailTimeoutDuration() time.Duration

连接超时时间

func (*BackendConfig) IncreaseConn

func (this *BackendConfig) IncreaseConn()

增加连接数

func (*BackendConfig) IncreaseFails

func (this *BackendConfig) IncreaseFails() uint

增加错误次数

func (*BackendConfig) ReadTimeoutDuration

func (this *BackendConfig) ReadTimeoutDuration() time.Duration

读取超时时间

func (*BackendConfig) Validate

func (this *BackendConfig) Validate() error

校验

type BackendList

type BackendList struct {
	Backends   []*BackendConfig  `yaml:"backends" json:"backends"`
	Scheduling *SchedulingConfig `yaml:"scheduling" json:"scheduling"` // 调度算法选项
	// contains filtered or unexported fields
}

BackendList定义

func (*BackendList) AddBackend

func (this *BackendList) AddBackend(backend *BackendConfig)

添加Backend

func (*BackendList) AllBackends

func (this *BackendList) AllBackends() []*BackendConfig

所有的Backends

func (*BackendList) DeleteBackend

func (this *BackendList) DeleteBackend(backendId string)

删除后端服务器

func (*BackendList) FindBackend

func (this *BackendList) FindBackend(backendId string) *BackendConfig

根据ID查找后端服务器

func (*BackendList) NextBackend

func (this *BackendList) NextBackend(options maps.Map) *BackendConfig

取得下一个可用的后端服务

func (*BackendList) SchedulingConfig

func (this *BackendList) SchedulingConfig() *SchedulingConfig

调度算法

func (*BackendList) SetSchedulingConfig

func (this *BackendList) SetSchedulingConfig(scheduling *SchedulingConfig)

设置调度算法

func (*BackendList) SetupScheduling

func (this *BackendList) SetupScheduling(isBackup bool)

设置调度算法

func (*BackendList) ValidateBackends

func (this *BackendList) ValidateBackends() error

校验

type BackendListInterface

type BackendListInterface interface {
	// 校验
	ValidateBackends() error

	// 添加Backend
	AddBackend(backend *BackendConfig)

	// 所有的Backends
	AllBackends() []*BackendConfig

	// 删除后端服务器
	DeleteBackend(backendId string)

	// 查找后端服务器
	FindBackend(backendId string) *BackendConfig

	// 调度算法
	SchedulingConfig() *SchedulingConfig

	// 设置调度算法
	SetSchedulingConfig(scheduling *SchedulingConfig)
}

BackendList接口定义

type Board

type Board struct {
	Charts []*BoardChart `yaml:"charts" json:"charts"`
}

看板

func NewBoard

func NewBoard() *Board

获取新对象

func (*Board) AddChart

func (this *Board) AddChart(widgetId string, chartId string)

添加Chart

func (*Board) HasChart

func (this *Board) HasChart(chartId string) bool

判断是否在使用某个Chart

func (*Board) MoveChart

func (this *Board) MoveChart(fromIndex int, toIndex int)

移动Chart

func (*Board) RemoveChart

func (this *Board) RemoveChart(chartId string)

移除某个Chart

type BoardChart

type BoardChart struct {
	WidgetId string `yaml:"widgetId" json:"widgetId"`
	ChartId  string `yaml:"chartId" json:"chartId"`
}

看板图表

func (*BoardChart) FindChart

func (this *BoardChart) FindChart() (widget *widgets.Widget, chart *widgets.Chart)

查找Chart实例

type CacheConfig

type CacheConfig struct {
	Filename    string   `yaml:"filename" json:"filename"`       // 文件名
	PolicyFiles []string `yaml:"policyFiles" json:"policyFiles"` // 策略文件
}

缓存管理

func NewCacheConfig

func NewCacheConfig() *CacheConfig

获取新对象

func SharedCacheConfig

func SharedCacheConfig() (*CacheConfig, error)

加载对象,无论如何都会返回一个对象

func (*CacheConfig) AddPolicy

func (this *CacheConfig) AddPolicy(file string)

添加缓存策略

func (*CacheConfig) DeletePolicy

func (this *CacheConfig) DeletePolicy(file string)

删除缓存策略

func (*CacheConfig) FindAllPolicies

func (this *CacheConfig) FindAllPolicies() []*shared.CachePolicy

查找所有的缓存策略

func (*CacheConfig) Save

func (this *CacheConfig) Save() error

保存

type FastcgiConfig

type FastcgiConfig struct {
	shared.HeaderList `yaml:",inline"`

	On bool   `yaml:"on" json:"on"`
	Id string `yaml:"id" json:"id"`

	// fastcgi地址配置
	// 支持unix:/tmp/php-fpm.sock ...
	Pass string `yaml:"pass" json:"pass"`

	Index       string            `yaml:"index" json:"index"`             //@TODO
	Params      map[string]string `yaml:"params" json:"params"`           //@TODO
	ReadTimeout string            `yaml:"readTimeout" json:"readTimeout"` // @TODO 读取超时时间
	SendTimeout string            `yaml:"sendTimeout" json:"sendTimeout"` // @TODO 发送超时时间
	ConnTimeout string            `yaml:"connTimeout" json:"connTimeout"` // @TODO 连接超时时间
	PoolSize    int               `yaml:"poolSize" json:"poolSize"`       // 连接池尺寸
	// contains filtered or unexported fields
}

Fastcgi配置 参考:http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html

func NewFastcgiConfig

func NewFastcgiConfig() *FastcgiConfig

获取新对象

func (*FastcgiConfig) Address

func (this *FastcgiConfig) Address() string

网络地址

func (*FastcgiConfig) FilterParams

func (this *FastcgiConfig) FilterParams(req *http.Request) maps.Map

过滤参数

func (*FastcgiConfig) Network

func (this *FastcgiConfig) Network() string

网络协议

func (*FastcgiConfig) Param

func (this *FastcgiConfig) Param(paramName string) string

读取参数

func (*FastcgiConfig) ReadTimeoutDuration

func (this *FastcgiConfig) ReadTimeoutDuration() time.Duration

超时时间

func (*FastcgiConfig) Validate

func (this *FastcgiConfig) Validate() error

校验配置

type FastcgiList

type FastcgiList struct {
	Fastcgi []*FastcgiConfig `yaml:"fastcgi" json:"fastcgi"`
}

FastcgiList定义

func (*FastcgiList) AddFastcgi

func (this *FastcgiList) AddFastcgi(fastcgi *FastcgiConfig)

添加Fastcgi

func (*FastcgiList) AllFastcgi

func (this *FastcgiList) AllFastcgi() []*FastcgiConfig

取得所有的Fastcgi

func (*FastcgiList) FindFastcgi

func (this *FastcgiList) FindFastcgi(fastcgiId string) *FastcgiConfig

根据ID查找Fastcgi

func (*FastcgiList) NextFastcgi

func (this *FastcgiList) NextFastcgi() *FastcgiConfig

查找下一个可用的Fastcgi

func (*FastcgiList) RemoveFastcgi

func (this *FastcgiList) RemoveFastcgi(fastcgiId string)

删除Fastcgi

func (*FastcgiList) ValidateFastcgi

func (this *FastcgiList) ValidateFastcgi() error

校验

type FastcgiListInterface

type FastcgiListInterface interface {
	// 校验
	ValidateFastcgi() error

	// 取得所有的Fastcgi
	AllFastcgi() []*FastcgiConfig

	// 根据ID查找Fastcgi
	FindFastcgi(fastcgiId string) *FastcgiConfig

	// 添加Fastcgi
	AddFastcgi(fastcgi *FastcgiConfig)

	// 删除Fastcgi
	RemoveFastcgi(fastcgiId string)

	// 查找下一个可用的Fastcgi
	NextFastcgi() *FastcgiConfig
}

FastcgiList接口定义

type ListenerConfig

type ListenerConfig struct {
	Key     string // 区分用的Key
	Address string
	Http    bool
	SSL     *SSLConfig
	Servers []*ServerConfig
}

本地监听服务配置

func ParseConfigs

func ParseConfigs() ([]*ListenerConfig, error)

从配置文件中分析配置

func (*ListenerConfig) AddServer

func (this *ListenerConfig) AddServer(serverConfig *ServerConfig)

添加服务

func (*ListenerConfig) FindNamedServer

func (this *ListenerConfig) FindNamedServer(name string) (serverConfig *ServerConfig, serverName string)

根据域名来查找匹配的域名 @TODO 把查找的结果加入缓存

func (*ListenerConfig) Port

func (this *ListenerConfig) Port() int

获取当前监听服务的端口

type LocationConfig

type LocationConfig struct {
	shared.HeaderList `yaml:",inline"`
	FastcgiList       `yaml:",inline"`
	RewriteList       `yaml:",inline"`
	BackendList       `yaml:",inline"`

	On      bool   `yaml:"on" json:"on"`           // 是否开启
	Id      string `yaml:"id" json:"id"`           // ID
	Pattern string `yaml:"pattern" json:"pattern"` // 匹配规则

	Async         bool                 `yaml:"async" json:"async"`                 // 是否异步请求 @TODO
	Notify        []interface{}        `yaml:"notify" json:"notify"`               // 转发请求,可以配置转发策略 @TODO
	LogOnly       bool                 `yaml:"logOnly" json:"logOnly"`             // 是否只记录日志 @TODO
	Root          string               `yaml:"root" json:"root"`                   // 资源根目录
	Index         []string             `yaml:"index" json:"index"`                 // 默认文件
	Charset       string               `yaml:"charset" json:"charset"`             // 字符集设置
	MaxBodySize   string               `yaml:"maxBodySize" json:"maxBodySize"`     // 请求body最大尺寸
	GzipLevel     int8                 `yaml:"gzipLevel" json:"gzipLevel"`         // Gzip压缩级别
	GzipMinLength string               `yaml:"gzipMinLength" json:"gzipMinLength"` // 需要压缩的最小内容尺寸
	AccessPolicy  *shared.AccessPolicy `yaml:"accessPolicy" json:"accessPolicy"`   // 访问控制

	// 日志
	DisableAccessLog bool               `yaml:"disableAccessLog" json:"disableAccessLog"` // 是否禁用访问日志
	AccessLog        []*AccessLogConfig `yaml:"accessLog" json:"accessLog"`               // 访问日志设置 TODO

	// 参考:http://nginx.org/en/docs/http/ngx_http_access_module.html
	Allow []string `yaml:"allow" json:"allow"` // 允许的终端地址 @TODO
	Deny  []string `yaml:"deny" json:"deny"`   // 禁止的终端地址 @TODO

	Proxy string `yaml:proxy" json:"proxy"` //  代理配置 @TODO

	CachePolicy string `yaml:"cachePolicy" json:"cachePolicy"` // 缓存策略
	CacheOn     bool   `yaml:"cacheOn" json:"cacheOn"`         // 缓存是否打开 TODO

	// websocket设置
	Websocket *WebsocketConfig `yaml:"websocket" json:"websocket"`
	// contains filtered or unexported fields
}

路径配置

func NewLocation

func NewLocation() *LocationConfig

获取新对象

func (*LocationConfig) CachePolicyObject

func (this *LocationConfig) CachePolicyObject() *shared.CachePolicy

缓存策略

func (*LocationConfig) GzipMinBytes

func (this *LocationConfig) GzipMinBytes() int64

可压缩最小尺寸

func (*LocationConfig) IsCaseInsensitive

func (this *LocationConfig) IsCaseInsensitive() bool

是否大小写非敏感

func (*LocationConfig) IsReverse

func (this *LocationConfig) IsReverse() bool

是否翻转

func (*LocationConfig) Match

func (this *LocationConfig) Match(path string) (map[string]string, bool)

判断是否匹配路径

func (*LocationConfig) MaxBodyBytes

func (this *LocationConfig) MaxBodyBytes() int64

最大Body尺寸

func (*LocationConfig) PatternString

func (this *LocationConfig) PatternString() string

模式字符串 去掉了模式字符

func (*LocationConfig) PatternType

func (this *LocationConfig) PatternType() int

模式类型

func (*LocationConfig) SetPattern

func (this *LocationConfig) SetPattern(pattern string, patternType int, caseInsensitive bool, reverse bool)

组合参数为一个字符串

func (*LocationConfig) Validate

func (this *LocationConfig) Validate() error

校验

type LocationPatternType

type LocationPatternType = int

匹配类型

type RewriteCond

type RewriteCond struct {
	Id string `yaml:"id" json:"id"` // ID

	// 要测试的字符串
	// 其中可以使用跟请求相关的参数,比如:
	// ${arg.name}, ${requestPath}
	Param string `yaml:"param" json:"param"`

	// 运算符
	Operator RewriteOperator `yaml:"operator" json:"operator"`

	// 对比
	Value string `yaml:"value" json:"value"`
	// contains filtered or unexported fields
}

重写条件定义

func NewRewriteCond

func NewRewriteCond() *RewriteCond

取得新对象

func (*RewriteCond) Match

func (this *RewriteCond) Match(formatter func(source string) string) bool

将此条件应用于请求,检查是否匹配

func (*RewriteCond) Validate

func (this *RewriteCond) Validate() error

校验配置

type RewriteList

type RewriteList struct {
	Rewrite []*RewriteRule `yaml:"rewrite" json:"rewrite"`
}

RewriteList定义

func (*RewriteList) AddRewriteRule

func (this *RewriteList) AddRewriteRule(rewrite *RewriteRule)

添加Rewrite

func (*RewriteList) AllRewriteRules

func (this *RewriteList) AllRewriteRules() []*RewriteRule

取得所有的Rewrite

func (*RewriteList) FindRewriteRule

func (this *RewriteList) FindRewriteRule(rewriteId string) *RewriteRule

根据ID查找Rewrite

func (*RewriteList) RemoveRewriteRule

func (this *RewriteList) RemoveRewriteRule(rewriteId string)

删除Rewrite

func (*RewriteList) ValidateRewriteRules

func (this *RewriteList) ValidateRewriteRules() error

校验

type RewriteListInterface

type RewriteListInterface interface {
	// 校验
	ValidateRewriteRules() error

	// 取得所有的Rewrite
	AllRewriteRules() []*RewriteRule

	// 根据ID查找Rewrite
	FindRewriteRule(rewriteId string) *RewriteRule

	// 添加Rewrite
	AddRewriteRule(rewrite *RewriteRule)

	// 删除Rewrite
	RemoveRewriteRule(rewriteId string)
}

RewriteList接口

type RewriteOperator

type RewriteOperator = string

运算符定义

type RewriteRule

type RewriteRule struct {
	shared.HeaderList `yaml:",inline"`

	On bool   `yaml:"on" json:"on"` // 是否开启
	Id string `yaml:"id" json:"id"` // ID

	// 开启的条件
	// 语法为:cond param operator value 比如:
	// - cond ${status} gte 200
	// - cond ${arg.name} eq lily
	// - cond ${requestPath} regexp .*\.png
	Cond []*RewriteCond `yaml:"cond" json:"cond"`

	// 规则
	// 语法为:pattern regexp 比如:
	// - pattern ^/article/(\d+).html
	Pattern string `yaml:"pattern" json:"pattern"`

	// 要替换成的URL
	// 支持反向引用:${0}, ${1}, ...,也支持?P<NAME>语法
	// - 如果以 proxy:// 开头,表示目标为代理,首先会尝试作为代理ID请求,如果找不到,会尝试作为代理Host请求
	Replace string `yaml:"replace" json:"replace"`

	// 选项
	Flags       []string `yaml:"flags" json:"flags"`
	FlagOptions maps.Map `yaml:"flagOptions" json:"flagOptions"` // flag => options map
	// contains filtered or unexported fields
}

重写规则定义

参考 - http://nginx.org/en/docs/http/ngx_http_rewrite_module.html - https://httpd.apache.org/docs/current/mod/mod_rewrite.html - https://httpd.apache.org/docs/2.4/rewrite/flags.html

func NewRewriteRule

func NewRewriteRule() *RewriteRule

获取新对象

func (*RewriteRule) AddCond

func (this *RewriteRule) AddCond(cond *RewriteCond)

添加过滤条件

func (*RewriteRule) AddFlag

func (this *RewriteRule) AddFlag(flag string, options maps.Map)

添加Flag

func (*RewriteRule) IsExternalURL

func (this *RewriteRule) IsExternalURL(url string) bool

判断是否是外部URL

func (*RewriteRule) Match

func (this *RewriteRule) Match(requestPath string, formatter func(source string) string) (replace string, varMapping map[string]string, matched bool)

对某个请求执行规则

func (*RewriteRule) RedirectMode

func (this *RewriteRule) RedirectMode() string

跳转模式

func (*RewriteRule) ResetFlags

func (this *RewriteRule) ResetFlags()

重置模式

func (*RewriteRule) TargetProxy

func (this *RewriteRule) TargetProxy() string

获取目标类型

func (*RewriteRule) TargetType

func (this *RewriteRule) TargetType() int

获取目标类型

func (*RewriteRule) TargetURL

func (this *RewriteRule) TargetURL() string

获取目标URL

func (*RewriteRule) Validate

func (this *RewriteRule) Validate() error

校验

type SSLConfig

type SSLConfig struct {
	On             bool     `yaml:"on" json:"on"`                         // 是否开启
	Certificate    string   `yaml:"certificate" json:"certificate"`       // 证书文件
	CertificateKey string   `yaml:"certificateKey" json:"certificateKey"` // 密钥
	Listen         []string `yaml:"listen" json:"listen"`                 // 网络地址
}

SSL配置

func NewSSLConfig

func NewSSLConfig() *SSLConfig

获取新对象

func (*SSLConfig) Validate

func (this *SSLConfig) Validate() error

校验配置

type SchedulingConfig

type SchedulingConfig struct {
	Code    string   `yaml:"code" json:"code"`       // 类型
	Options maps.Map `yaml:"options" json:"options"` // 选项
}

调度算法配置

func NewSchedulingConfig

func NewSchedulingConfig() *SchedulingConfig

获取新对象

type ServerConfig

type ServerConfig struct {
	shared.HeaderList `yaml:",inline"`
	FastcgiList       `yaml:",inline"`
	RewriteList       `yaml:",inline"`
	BackendList       `yaml:",inline"`

	On bool `yaml:"on" json:"on"` // 是否开启 @TODO

	Id          string   `yaml:"id" json:"id"`                   // ID
	Description string   `yaml:"description" json:"description"` // 描述
	Name        []string `yaml:"name" json:"name"`               // 域名
	Http        bool     `yaml:"http" json:"http"`               // 是否支持HTTP

	// 监听地址
	Listen []string `yaml:"listen" json:"listen"`

	Root          string            `yaml:"root" json:"root"`                   // 资源根目录
	Index         []string          `yaml:"index" json:"index"`                 // 默认文件
	Charset       string            `yaml:"charset" json:"charset"`             // 字符集
	Locations     []*LocationConfig `yaml:"locations" json:"locations"`         // 地址配置
	MaxBodySize   string            `yaml:"maxBodySize" json:"maxBodySize"`     // 请求body最大尺寸
	GzipLevel     uint8             `yaml:"gzipLevel" json:"gzipLevel"`         // Gzip压缩级别
	GzipMinLength string            `yaml:"gzipMinLength" json:"gzipMinLength"` // 需要压缩的最小内容尺寸

	Async   bool     `yaml:"async" json:"async"`     // 请求是否异步处理 @TODO
	Notify  []string `yaml:"notify" json:"notify"`   // 请求转发地址 @TODO
	LogOnly bool     `yaml:"logOnly" json:"logOnly"` // 是否只记录日志 @TODO

	// 访问日志
	DisableAccessLog bool               `yaml:"disableAccessLog" json:"disableAccessLog"` // 是否禁用访问日志
	AccessLog        []*AccessLogConfig `yaml:"accessLog" json:"accessLog"`               // 访问日志,TODO

	// SSL
	SSL *SSLConfig `yaml:"ssl" json:"ssl"`

	// 参考:http://nginx.org/en/docs/http/ngx_http_access_module.html
	Allow []string `yaml:"allow" json:"allow"` //TODO
	Deny  []string `yaml:"deny" json:"deny"`   //TODO

	Filename string `yaml:"filename" json:"filename"` // 配置文件名

	Proxy string `yaml:"proxy" json:"proxy"` //  代理配置 TODO

	CachePolicy string `yaml:"cachePolicy" json:"cachePolicy"` // 缓存策略
	CacheOn     bool   `yaml:"cacheOn" json:"cacheOn"`         // 缓存是否打开

	// API相关
	API *api.APIConfig `yaml:"api" json:"api"` // API配置

	// 看板
	RealtimeBoard *Board `yaml:"realtimeBoard" json:"realtimeBoard"` // 即时看板
	StatBoard     *Board `yaml:"statBoard" json:"statBoard"`         // 统计看板
	// contains filtered or unexported fields
}

服务配置

func LoadServerConfigsFromDir

func LoadServerConfigsFromDir(dirPath string) []*ServerConfig

从目录中加载配置

func NewServerConfig

func NewServerConfig() *ServerConfig

取得一个新的服务配置

func NewServerConfigFromFile

func NewServerConfigFromFile(filename string) (*ServerConfig, error)

从配置文件中读取配置信息

func NewServerConfigFromId

func NewServerConfigFromId(serverId string) *ServerConfig

通过ID读取配置信息

func (*ServerConfig) AddListen

func (this *ServerConfig) AddListen(address string)

添加监听地址

func (*ServerConfig) AddLocation

func (this *ServerConfig) AddLocation(location *LocationConfig)

添加路径规则

func (*ServerConfig) AddName

func (this *ServerConfig) AddName(name ...string)

添加域名

func (*ServerConfig) CachePolicyObject

func (this *ServerConfig) CachePolicyObject() *shared.CachePolicy

缓存策略

func (*ServerConfig) Delete

func (this *ServerConfig) Delete() error

删除

func (*ServerConfig) FindBackendList

func (this *ServerConfig) FindBackendList(locationId string, websocket bool) (backendList BackendListInterface, err error)

查找后端服务器列表

func (*ServerConfig) FindFastcgiList

func (this *ServerConfig) FindFastcgiList(locationId string) (fastcgiList FastcgiListInterface, err error)

查找FastcgiList

func (*ServerConfig) FindHeaderList

func (this *ServerConfig) FindHeaderList(locationId string, backendId string, rewriteId string, fastcgiId string) (headerList shared.HeaderListInterface, err error)

查找HeaderList

func (*ServerConfig) FindLocation

func (this *ServerConfig) FindLocation(locationId string) *LocationConfig

根据Id查找Location

func (*ServerConfig) FindRewriteList

func (this *ServerConfig) FindRewriteList(locationId string) (rewriteList RewriteListInterface, err error)

查找重写规则

func (*ServerConfig) FirstName

func (this *ServerConfig) FirstName() string

取得第一个非泛解析的域名

func (*ServerConfig) GzipMinBytes

func (this *ServerConfig) GzipMinBytes() int64

可压缩最小尺寸

func (*ServerConfig) LocationAtIndex

func (this *ServerConfig) LocationAtIndex(index int) *LocationConfig

获取某个位置上的配置

func (*ServerConfig) MatchName

func (this *ServerConfig) MatchName(name string) (matchedName string, matched bool)

判断是否和域名匹配

func (*ServerConfig) MaxBodyBytes

func (this *ServerConfig) MaxBodyBytes() int64

最大Body尺寸

func (*ServerConfig) RemoveLocation

func (this *ServerConfig) RemoveLocation(locationId string)

删除Location

func (*ServerConfig) Save

func (this *ServerConfig) Save() error

保存

func (*ServerConfig) Validate

func (this *ServerConfig) Validate() error

校验配置

func (*ServerConfig) WriteToFile

func (this *ServerConfig) WriteToFile(path string) error

将配置写入文件

func (*ServerConfig) WriteToFilename

func (this *ServerConfig) WriteToFilename(filename string) error

将配置写入文件

type ServerList

type ServerList struct {
	Files []string `yaml:"files" json:"files"`
}

Server列表

func SharedServerList

func SharedServerList() (*ServerList, error)

取得Server列表

func (*ServerList) AddServer

func (this *ServerList) AddServer(serverFile string)

添加Server

func (*ServerList) FindAllServers

func (this *ServerList) FindAllServers() []*ServerConfig

查找所有Servers

func (*ServerList) MoveServer

func (this *ServerList) MoveServer(fromIndex int, toIndex int)

移动位置

func (*ServerList) RemoveServer

func (this *ServerList) RemoveServer(serverFile string)

删除Server

func (*ServerList) Save

func (this *ServerList) Save() error

保存

type WebsocketConfig

type WebsocketConfig struct {
	// 后端服务器列表
	BackendList `yaml:",inline"`

	On bool `yaml:"on" json:"on"` // 是否开启

	// 握手超时时间
	HandshakeTimeout string `yaml:"handshakeTimeout" json:"handshakeTimeout"`

	// 允许的域名,支持 www.example.com, example.com, .example.com, *.example.com
	AllowAllOrigins bool     `yaml:"allowAllOrigins" json:"allowAllOrigins"`
	Origins         []string `yaml:"origins" json:"origins"`

	// 转发方式
	ForwardMode WebsocketForwardMode `yaml:"forwardMode" json:"forwardMode"`
	// contains filtered or unexported fields
}

websocket设置

func NewWebsocketConfig

func NewWebsocketConfig() *WebsocketConfig

获取新对象

func (*WebsocketConfig) ForwardModeSummary

func (this *WebsocketConfig) ForwardModeSummary() maps.Map

转发模式名称

func (*WebsocketConfig) HandshakeTimeoutDuration

func (this *WebsocketConfig) HandshakeTimeoutDuration() time.Duration

获取握手超时时间

func (*WebsocketConfig) MatchOrigin

func (this *WebsocketConfig) MatchOrigin(origin string) bool

匹配域名

func (*WebsocketConfig) Validate

func (this *WebsocketConfig) Validate() error

校验

type WebsocketForwardMode

type WebsocketForwardMode = string

Websocket转发类型

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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