Documentation
¶
Index ¶
- func ContextWithAuthenticationType(parent context.Context, authType string) context.Context
- func ContextWithGroups(parent context.Context, groups []string) context.Context
- func ContextWithIDToken(parent context.Context, token interface{}) context.Context
- func ContextWithUserID(parent context.Context, userID int64) context.Context
- func ContextWithUsername(parent context.Context, username string) context.Context
- func GetAuthenticationTypeFromContext(ctx context.Context) (string, bool)
- func GetGroupsFromContext(ctx context.Context) ([]string, bool)
- func GetIDTokenFromContext(ctx context.Context) any
- func GetRealIPFromMetadata(ctx context.Context) string
- func GetSourceIPsFromMetadata(ctx context.Context) []string
- func GetUserAgentFromMetadata(ctx context.Context) string
- func GetUserIDFromContext(ctx context.Context) (int64, bool)
- func GetUsernameFromContext(ctx context.Context) (string, bool)
- func MetricAuditEventSendErrorsIncr(ctx context.Context)
- type Client
- func (c *Client) Dial(ctx context.Context, scode string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
- func (c *Client) UseDialOption(opts ...grpc.DialOption) *Client
- func (c *Client) UseStreamInterceptor(handlers ...grpc.StreamClientInterceptor) *Client
- func (c *Client) UseUnaryInterceptor(handlers ...grpc.UnaryClientInterceptor) *Client
- type Config
- type Server
- type TLSConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithAuthenticationType ¶ added in v0.3.8
func ContextWithGroups ¶ added in v0.3.8
func ContextWithIDToken ¶ added in v0.3.8
ContextWithIDToken xx
func ContextWithUserID ¶
func ContextWithUsername ¶ added in v0.3.8
func GetAuthenticationTypeFromContext ¶ added in v0.3.8
func GetGroupsFromContext ¶ added in v0.3.8
func GetIDTokenFromContext ¶ added in v0.3.8
func GetRealIPFromMetadata ¶ added in v0.3.8
GetRealIPFromMetadata 用于获取当前请求源 IP 地址,既 x-real-ip 或 x-forwarded-for 头
func GetSourceIPsFromMetadata ¶ added in v0.3.8
GetSourceIPsFromMetadata 用于获取当前请求的源 IP 列表,即 x-forwarded-for 头
func GetUserAgentFromMetadata ¶ added in v0.3.8
GetUserAgentFromMetadata 用于获取当前请求的 User-Agent
func GetUsernameFromContext ¶ added in v0.3.8
func MetricAuditEventSendErrorsIncr ¶ added in v0.3.8
MetricAuditEventSendErrorsIncr 推送审计事件失败次数+1
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 客户端
func (*Client) Dial ¶
func (c *Client) Dial(ctx context.Context, scode string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
Dial 用于创建连接
func (*Client) UseDialOption ¶
func (c *Client) UseDialOption(opts ...grpc.DialOption) *Client
UseDialOption 用于添加自定义连接参数
func (*Client) UseStreamInterceptor ¶
func (c *Client) UseStreamInterceptor(handlers ...grpc.StreamClientInterceptor) *Client
UseStreamInterceptor 用于添加自定义客户端流拦截器
func (*Client) UseUnaryInterceptor ¶
func (c *Client) UseUnaryInterceptor(handlers ...grpc.UnaryClientInterceptor) *Client
UseUnaryInterceptor 用于添加自定义客户端一元拦截器
type Config ¶
type Config struct {
GRPCAddress string
HTTPAddress string
KeepaliveTimeout time.Duration
// client
Scheme string
Authority string
APIEndpoint string
// tls
TLS TLSConfig
// 默认开启 http 与 grpc 服务
DisableGRPCServer bool
DisableHTTPServer bool
// contains filtered or unexported fields
}
Config server config
func (*Config) WithServerOption ¶ added in v0.3.8
func (c *Config) WithServerOption(opt ...grpc.ServerOption)
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server server instance
func (*Server) RegisterGateway ¶
RegisterGateway return the http server for registering service
func (*Server) UseServerOption ¶
func (s *Server) UseServerOption(opts ...grpc.ServerOption) *Server
UseServerOption 用于设置选项并初始化grpc server
type TLSConfig ¶
type TLSConfig struct {
// HTTPCertFile 用于 HTTP 网关证书
HTTPCertFile string
HTTPKeyFile string
// GRPCCertFile 用于 GRPC 网关证书
GRPCCertFile string
GRPCKeyFile string
// 用于验证客户端证书有效性,既:http_service.tls_client.cert_file 所签发的 ca 证书
GRPCCAFile string
// 用于基于 acme 协议的自动化证书申请
ACMEServer string
ACMEEmail string
ACMEDomains []string
ACMECacheDir string
}
TLSConfig xx
Click to show internal directories.
Click to hide internal directories.