config

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body struct {
	// 原始请求
	Raws []*Raw `default:"[{'contains': 'raw'}]" json:"raws" yaml:"raws" xml:"raws" toml:"raws"`
}

func (*Body) Check

func (b *Body) Check(check string) (checked bool)

type Client

type Client struct {
	// 名称
	Name string `json:"name" yaml:"name" xml:"name" toml:"name" validate:"required_without=Names"`
	// 名称列表
	Names []string `json:"names" yaml:"names" xml:"names" toml:"names" validate:"required_without=Name"`
	// 连接地址
	Addr string `json:"addr" yaml:"addr" xml:"addr" toml:"addr" validate:"required,url"`
}

type Cors

type Cors struct {
	// 是否开启
	Enabled *bool `json:"enabled" yaml:"enabled" xml:"enabled" toml:"enabled"`
	// 允许跨域访问的源
	Allows []string `default:"['*']" json:"allows" yaml:"allows" xml:"allows" toml:"allows"`
	// 允许的请求方法
	// nolint:lll
	Methods []string `default:"['GET', 'POST', 'PUT', 'DELETE']" json:"methods" yaml:"methods" xml:"methods" toml:"methods"`
	// 允许的请求头
	// nolint:lll
	Headers []string `default:"['Content-Type', 'Authorization']" json:"headers" yaml:"headers" xml:"headers" toml:"headers"`
}

type Gateway

type Gateway struct {
	// 是否开启
	Enabled *bool `default:"true" json:"enabled" yaml:"enabled" xml:"enabled" toml:"enabled"`
	// 名字
	Name string `default:"网关" json:"name" yaml:"name" xml:"name" toml:"name"`
	// 绑定监听主机
	Host string `json:"host" yaml:"host" xml:"host" toml:"host"`
	// 绑定监听端口
	Port int `default:"9001" json:"port" yaml:"port" xml:"port" toml:"port" validate:"required,min=1,max=65535"`
	// 路径
	Path string `json:"path" yaml:"path" xml:"path" toml:"path" validate:"omitempty,startswith=/,endsnotwith=/"`
	// 跨域
	Cors *Cors `json:"cors" yaml:"cors" xml:"cors" toml:"cors"`
	// 超时
	Timeout Timeout `json:"timeout" yaml:"timeout" xml:"timeout" toml:"timeout"`
	// 序列化
	Json Json `json:"json" yaml:"json" xml:"json" toml:"json"`
	// 头
	Header Header `json:"header" yaml:"header" xml:"header" toml:"header"`
	// 消息体
	Body Body `json:"body" yaml:"body" xml:"body" toml:"body"`
	// 模式
	Unescape *Unescape `json:"unescape" yaml:"unescape" xml:"unescape" toml:"unescape"`
}

func (*Gateway) Addr added in v0.3.5

func (g *Gateway) Addr() string

func (*Gateway) CorsEnabled added in v0.3.5

func (g *Gateway) CorsEnabled() bool

func (*Gateway) Enable added in v0.3.5

func (g *Gateway) Enable() bool

func (*Gateway) Options

func (g *Gateway) Options() (options []runtime.ServeMuxOption)
type Header struct {
	// 是否启用默认行为
	Default *bool `default:"true" json:"default" yaml:"default" xml:"default" toml:"default"`
	// 删除列表
	Removes []Remove `json:"removes" yaml:"removes" xml:"removes" toml:"removes"`
	// 输入头匹配列表
	// nolint: lll
	Ins []Matcher `json:"ins" yaml:"ins" xml:"ins" toml:"ins"`
	// 输出头匹配列表
	Outs []Matcher `json:"outs" yaml:"outs" xml:"outs" toml:"outs"`
	// 保留
	// 符合要求的请求头,会在返回时原样返回
	Reserves []Matcher `json:"reserves" yaml:"reserves" xml:"reserves" toml:"reserves"`

	DefaultRemoves  []Remove  `default:"[{'prefix': 'http-'}]"`
	DefaultIns      []Matcher `default:"[{'prefix': 'x-forwarded'}]"`
	DefaultReserves []Matcher `default:"[{'prefix': 'internal-'}]"`
}

func (*Header) TestIns

func (h *Header) TestIns(key string) (new string, match bool)

func (*Header) TestOuts

func (h *Header) TestOuts(key string) (new string, match bool)

func (*Header) TestRemove

func (h *Header) TestRemove(key string) (new string, match bool)

func (*Header) TestReserves added in v0.4.4

func (h *Header) TestReserves(key string) (new string, match bool)

type Json

type Json struct {
	// 是否允许多行
	Multiline bool `json:"multiline" yaml:"multiline" xml:"multiline" toml:"multiline"`
	// 前缀
	Indent string `json:"indent" yaml:"indent" xml:"indent" toml:"indent"`
	// 允许部分
	Partial bool `json:"partial" yaml:"partial" xml:"partial" toml:"partial"`
	// 选项列表
	// nolint: lll
	Options []string `default:"['enum_as_numbers', 'name_as_proto']" json:"options" yaml:"options" xml:"options" toml:"options"`
	// 是否允许返回零值
	Unpopulated bool `json:"unpopulated" yaml:"unpopulated" xml:"unpopulated" toml:"unpopulated"`
	// 是否允许丢弃
	Discard *bool `default:"true" json:"discard" yaml:"discard" xml:"discard" toml:"discard"`
}

type Keepalive

type Keepalive struct {
	// 保持时长
	Time time.Duration `default:"10s" json:"time" yaml:"time" xml:"time" toml:"time"`
	// 超时
	Timeout time.Duration `default:"3s" json:"timeout" yaml:"timeout" xml:"timeout" toml:"timeout"`
	// 空闲时长
	Idle time.Duration `default:"3s" json:"idle" yaml:"idle" xml:"idle" toml:"idle"`
	// 策略
	Policy KeepalivePolicy `json:"policy" yaml:"policy" xml:"policy" toml:"policy"`
}

type KeepalivePolicy

type KeepalivePolicy struct {
	// 无流许可
	Permit bool `default:"true" json:"permit" yaml:"permit" xml:"permit" toml:"permit"`
}

type Matcher

type Matcher struct {
	// 等于
	Equal string `json:"equal" yaml:"equal" xml:"equal" toml:"equal"`
	// 前缀
	Prefix string `json:"prefix" yaml:"prefix" xml:"prefix" toml:"suffix"`
	// 后缀
	Suffix string `json:"suffix" yaml:"suffix" xml:"suffix" toml:"suffix"`
	// 包含
	Contains string `json:"contains" yaml:"contains" xml:"contains" toml:"contains"`
}

func (*Matcher) Test

func (m *Matcher) Test(key string) (new string, match bool)

type Msg

type Msg struct {
	// 发送大小
	// 4GB
	Send gox.Bytes `default:"4GB" json:"send" yaml:"send" xml:"send" toml:"send"`
	// 接收大小
	// 4GB
	Receive gox.Bytes `default:"4GB" json:"receive" yaml:"receive" xml:"receive" toml:"receive"`
}

type Options

type Options struct {
	// 大小配置
	Size Size `json:"size" yaml:"size" xml:"size" toml:"size"`
	// 长连接
	Keepalive Keepalive `json:"keepalive" yaml:"keepalive" xml:"keepalive" toml:"keepalive"`
}

type Raw

type Raw struct {
	// 前缀
	Prefix string `json:"prefix" yaml:"prefix" xml:"prefix" toml:"prefix"`
	// 后缀
	Suffix string `json:"suffix" yaml:"suffix" xml:"suffix" toml:"suffix"`
	// 包含
	Contains string `default:"Raw" json:"contains" yaml:"contains" xml:"contains" toml:"contains"`
}

func (*Raw) Check

func (r *Raw) Check(check string) (checked bool)

type Remove

type Remove struct {
	// 前缀
	Prefix string `json:"prefix" yaml:"prefix" xml:"prefix" toml:"suffix"`
	// 后缀
	Suffix string `json:"suffix" yaml:"suffix" xml:"suffix" toml:"suffix"`
}

func (*Remove) Test

func (r *Remove) Test(key string) (new string, match bool)

type Server

type Server struct {
	// 名字
	Name string `default:"gRPC" json:"name" yaml:"name" xml:"name" toml:"name"`
	// 绑定监听主机
	Host string `json:"host" yaml:"host" xml:"host" toml:"host"`
	// 绑定监听端口
	Port int `default:"9001" json:"port" yaml:"port" xml:"port" toml:"port" validate:"required,min=1,max=65535"`
	// 反射
	// 可以通过配置反射来开启服务器反射字段和方法的特性,方便客户端通过反射来调用方法
	Reflection *bool `default:"true" json:"reflection" yaml:"reflection" xml:"reflection" toml:"reflection"`
}

func (*Server) Addr

func (s *Server) Addr() string

type Size

type Size struct {
	// 消息
	Msg Msg `json:"msg" yaml:"msg" xml:"msg" toml:"msg" validate:"required"`
	// 窗口
	Window Window `json:"window" yaml:"window" xml:"window" toml:"window" validate:"required"`
}

type Timeout

type Timeout struct {
	// 读
	Read time.Duration `default:"15s" json:"read" yaml:"read" xml:"read" toml:"read"`
	// 头
	Header time.Duration `default:"15s" json:"header" yaml:"header" xml:"header" toml:"header"`
}

type Unescape

type Unescape struct {
	// 模式
	Mode runtime.UnescapingMode `json:"mode" yaml:"mode" xml:"mode" toml:"mode" validate:"max=3"`
}

type Window

type Window struct {
	// 初始
	// 1GB
	Initial gox.Bytes `default:"1GB" json:"initial" yaml:"initial" xml:"initial" toml:"initial"`
	// 连接
	// 1GB
	Connection gox.Bytes `default:"1GB" json:"connection" yaml:"connection" xml:"connection" toml:"connection"`
}

Jump to

Keyboard shortcuts

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