Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Addr string // HTTP server address // HTTP服务器地址
SwaggerDir string // Directory containing swagger files // 包含swagger文件的目录
ReadTimeout types.Duration // HTTP read timeout // HTTP读取超时时间
WriteTimeout types.Duration // HTTP write timeout // HTTP写入超时时间
ShutdownTimeout types.Duration // Graceful shutdown timeout // 优雅关闭超时时间
}
Config holds the configuration for gateway server 网关服务器配置
func DefaultGatewayConfig ¶
func DefaultGatewayConfig() *Config
DefaultGatewayConfig returns a default configuration for gateway 返回默认网关配置
type Gateway ¶
type Gateway struct {
RegisterItems []GatewayRegisterItem // Registration items with endpoints // 带端点的注册项
// contains filtered or unexported fields
}
Gateway implements the Server interface for grpc-gateway Gateway 实现了 grpc-gateway 的 Server 接口
func New ¶
func New(cfg *Config, register []GatewayRegisterItem, serveMuxOptions ...runtime.ServeMuxOption) *Gateway
New creates a new Gateway instance 创建一个新的 Gateway 实例
func (*Gateway) ServeSwaggerUI ¶
ServeSwaggerUI serves swagger UI if enabled 如果启用了swagger,则提供swagger UI服务
type GatewayRegisterFunc ¶
type GatewayRegisterFunc func(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) error
GatewayRegisterFunc defines the function type for registering handlers to the gateway 定义网关处理器注册函数类型
type GatewayRegisterItem ¶
type GatewayRegisterItem struct {
Func GatewayRegisterFunc // Registration function // 注册函数
Endpoint string // gRPC endpoint address // gRPC 端点地址
DialOpts []grpc.DialOption // gRPC dial options // gRPC 拨号选项
}
GatewayRegisterItem defines the registration function and its corresponding endpoint 定义注册项,包含注册函数及其对应的端点
Click to show internal directories.
Click to hide internal directories.