gateway

package
v0.1.6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterHandler added in v0.1.6

func RegisterHandler(e *gin.Engine, handlerFunc func(mux *runtime.ServeMux), serveMuxOptions ...runtime.ServeMuxOption)

RegisterHandler registers a handler function with gin 注册一个处理器函数与gin 支持使用 gin 实现 grpc-gateway 的 http server

Types

type Config

type Config struct {
	Addr            string         `mapstructure:"addr" yaml:"addr"`                       // HTTP server address // HTTP服务器地址
	SwaggerDir      string         `mapstructure:"swaggerDir" yaml:"swaggerDir"`           // Directory containing swagger files // 包含swagger文件的目录
	ReadTimeout     types.Duration `mapstructure:"readTimeout" yaml:"readTimeout"`         // HTTP read timeout // HTTP读取超时时间
	WriteTimeout    types.Duration `mapstructure:"writeTimeout" yaml:"writeTimeout"`       // HTTP write timeout // HTTP写入超时时间
	ShutdownTimeout types.Duration `mapstructure:"shutdownTimeout" yaml:"shutdownTimeout"` // 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 {
	// contains filtered or unexported fields
}

Gateway implements the Server interface for grpc-gateway Gateway 实现了 grpc-gateway 的 Server 接口

func New

func New(cfg *Config, handlerFunc func(mux *runtime.ServeMux), 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 方法

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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