gateway

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2025 License: BSD-3-Clause Imports: 10 Imported by: 0

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) Get

func (g *Gateway) Get() any

Get implements the Server interface 实现 Server 接口的 Get 方法

func (*Gateway) ServeSwaggerUI

func (g *Gateway) ServeSwaggerUI(w http.ResponseWriter, r *http.Request, pathPrefix string)

ServeSwaggerUI serves swagger UI if enabled 如果启用了swagger,则提供swagger UI服务

func (*Gateway) Start

func (g *Gateway) Start(ctx context.Context) error

Start implements the Server interface 实现 Server 接口的 Start 方法

func (*Gateway) Stop

func (g *Gateway) Stop(ctx context.Context) error

Stop implements the Server interface 实现 Server 接口的 Stop 方法

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 定义注册项,包含注册函数及其对应的端点

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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