Documentation ¶
Index ¶
- Constants
- func GRPCProxy(h interface{}) gin.HandlerFunc
- type Component
- func (c *Component) BuildWebsocket(opts ...WebSocketOption) *WebSocket
- func (c *Component) GetEmbedWrapper() *EmbedWrapper
- func (c *Component) GracefulStop(ctx context.Context) error
- func (c *Component) HTTPEmbedFs() http.FileSystem
- func (c *Component) Info() *server.ServiceInfo
- func (c *Component) Init() error
- func (c *Component) Listener() net.Listener
- func (c *Component) Name() string
- func (c *Component) PackageName() string
- func (c *Component) RegisterRouteComment(method, path, comment string)
- func (c *Component) Start() error
- func (c *Component) Stop() error
- func (c *Component) Upgrade(pattern string, ws *WebSocket, handler WebSocketFunc) gin.IRoutes
- type Config
- type Container
- type EmbedWrapper
- type Option
- func WithContextTimeout(timeout time.Duration) Option
- func WithEmbedFs(fs embed.FS) Option
- func WithHost(host string) Option
- func WithLogger(logger *elog.Component) Option
- func WithNetwork(network string) Option
- func WithPort(port int) Option
- func WithRecoveryFunc(f gin.RecoveryFunc) Option
- func WithSentinelBlockFallback(fn func(*gin.Context)) Option
- func WithSentinelResourceExtractor(fn func(*gin.Context) string) Option
- func WithServerReadHeaderTimeout(timeout time.Duration) Option
- func WithServerReadTimeout(timeout time.Duration) Option
- func WithServerWriteTimeout(timeout time.Duration) Option
- func WithTLSSessionCache(tsc tls.ClientSessionCache) Option
- func WithTrustedPlatform(trustedPlatform string) Option
- type WebSocket
- type WebSocketConn
- type WebSocketFunc
- type WebSocketOption
Constants ¶
const ( // HeaderAcceptEncoding ... HeaderAcceptEncoding = "Accept-Encoding" // HeaderContentType ... HeaderContentType = "Content-Type" // HeaderGRPCPROXYError ... HeaderGRPCPROXYError = "GRPC-Proxy-Error" // MIMEApplicationJSON ... MIMEApplicationJSON = "application/json" // MIMEApplicationJSONCharsetUTF8 ... MIMEApplicationJSONCharsetUTF8 = MIMEApplicationJSON + "; " + charsetUTF8 // MIMEApplicationProtobuf ... MIMEApplicationProtobuf = "application/protobuf" )
const PackageName = "server.egin"
PackageName 包名
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Component ¶
Component ...
func (*Component) BuildWebsocket ¶
func (c *Component) BuildWebsocket(opts ...WebSocketOption) *WebSocket
BuildWebsocket ..
func (*Component) GetEmbedWrapper ¶
func (c *Component) GetEmbedWrapper() *EmbedWrapper
GetEmbedWrapper http的文件系统
func (*Component) GracefulStop ¶
GracefulStop implements server.Component interface it will stop gin server gracefully
func (*Component) HTTPEmbedFs ¶
func (c *Component) HTTPEmbedFs() http.FileSystem
HTTPEmbedFs http的文件系统
func (*Component) Info ¶
func (c *Component) Info() *server.ServiceInfo
Info returns server info, used by governor and consumer balancer
func (*Component) RegisterRouteComment ¶
RegisterRouteComment 注册路由注释
type Config ¶
type Config struct { Host string // IP地址,默认0.0.0.0 Port int // PORT端口,默认9001 Mode string // gin的模式,默认是release模式 Network string ServerReadTimeout time.Duration // 服务端,用于读取io报文过慢的timeout,通常用于互联网网络收包过慢,如果你的go在最外层,可以使用他,默认不启用。 ServerReadHeaderTimeout time.Duration // 服务端,用于读取io报文过慢的timeout,通常用于互联网网络收包过慢,如果你的go在最外层,可以使用他,默认不启用。 ServerWriteTimeout time.Duration // 服务端,用于读取io报文过慢的timeout,通常用于互联网网络收包过慢,如果你的go在最外层,可以使用他,默认不启用。 // ServerHTTPTimout time.Duration // 这个是HTTP包提供的,可以用于IO,或者密集型计算,做timeout处理,有一次goroutine操作,然后没走一些流程,cancel体验不好,暂时先不用 ContextTimeout time.Duration // 只能用于IO操作,才能触发,默认不启用 EnableMetricInterceptor bool // 是否开启监控,默认开启 EnableTraceInterceptor bool // 是否开启链路追踪,默认开启 EnableLocalMainIP bool // 自动获取ip地址 SlowLogThreshold time.Duration // 服务慢日志,默认500ms EnableAccessInterceptor bool // 是否开启,记录请求数据 EnableAccessInterceptorReq bool // 是否开启记录请求参数,默认不开启 EnableAccessInterceptorRes bool // 是否开启记录响应参数,默认不开启 AccessInterceptorReqResFilter string // AccessInterceptorReq 过滤器,只有符合过滤器的请求才会记录 Req 和 Res EnableTrustedCustomHeader bool // 是否开启自定义header头,记录数据往链路后传递,默认不开启 EnableSentinel bool // 是否开启限流,默认不开启 WebsocketHandshakeTimeout time.Duration // 握手时间 WebsocketReadBufferSize int // WebsocketReadBufferSize WebsocketWriteBufferSize int // WebsocketWriteBufferSize EnableWebsocketCompression bool // 是否开通压缩 EnableWebsocketCheckOrigin bool // 是否支持跨域 EnableTLS bool // 是否进入 https 模式 TLSCertFile string // https 证书 TLSKeyFile string // https 私钥 TLSClientAuth string // https 客户端认证方式默认为 NoClientCert(NoClientCert,RequestClientCert,RequireAnyClientCert,VerifyClientCertIfGiven,RequireAndVerifyClientCert) TLSClientCAs []string // https client的ca,当需要双向认证的时候指定可以倒入自签证书 TrustedPlatform string // 需要用户换成自己的CDN名字,获取客户端IP地址 EmbedPath string // 嵌入embed path数据 TLSSessionCache tls.ClientSessionCache // contains filtered or unexported fields }
Config HTTP config
func (*Config) ClientAuthType ¶
func (config *Config) ClientAuthType() tls.ClientAuthType
ClientAuthType 客户端auth类型
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container defines a component instance.
func DefaultContainer ¶
func DefaultContainer() *Container
DefaultContainer returns an default container.
type EmbedWrapper ¶
type EmbedWrapper struct {
// contains filtered or unexported fields
}
EmbedWrapper 嵌入普通的静态资源的wrapper
type Option ¶
type Option func(c *Container)
Option overrides a Container's default configuration.
func WithContextTimeout ¶
WithContextTimeout 设置 context 超时时间
func WithRecoveryFunc ¶ added in v1.1.6
func WithRecoveryFunc(f gin.RecoveryFunc) Option
WithRecoveryFunc 设置 recovery func
func WithSentinelBlockFallback ¶
WithSentinelBlockFallback 限流后的返回数据
func WithSentinelResourceExtractor ¶
WithSentinelResourceExtractor 资源命名方式
func WithServerReadHeaderTimeout ¶
WithServerReadHeaderTimeout 设置超时时间
func WithServerReadTimeout ¶
WithServerReadTimeout 设置超时时间
func WithServerWriteTimeout ¶
WithServerWriteTimeout 设置超时时间
func WithTLSSessionCache ¶
func WithTLSSessionCache(tsc tls.ClientSessionCache) Option
WithTLSSessionCache TLS Session 缓存
func WithTrustedPlatform ¶
WithTrustedPlatform 信任的Header头,获取客户端IP地址
type WebSocket ¶
WebSocket ..
func (*WebSocket) Upgrade ¶
func (ws *WebSocket) Upgrade(w http.ResponseWriter, r *http.Request, c *gin.Context, handler WebSocketFunc)
Upgrade get upgrage request
type WebSocketConn ¶
WebSocketConn ...