Documentation ¶
Index ¶
Constants ¶
View Source
const ( DefaultAddr = ":8888" // 默认地址 DefaultGrpcAddr = ":5001" // 默认grpc地址 DefaultGrpcNetwork = "tcp" // 默认grpc DefaultSwaggerDir = "/swagger" )
参考:https://github.com/grpc-ecosystem/grpc-gateway/tree/master/examples/gateway
Variables ¶
This section is empty.
Functions ¶
func Run ¶
开启一个网关服务 go gateway.Run(
ctx, gateway.WithAddr(":8888"), gateway.WithGRPCServer("tcp", ":5001"), gateway.WithSwaggerDir("/swagger"), gateway.WithHandle(pb.RegisterRbacServiceHandler), )
Run starts a HTTP server and blocks while running if successful.// The server will be shutdown when "ctx" is canceled.
Types ¶
type Options ¶
type Options struct { // Addr is the address to listen Addr string // GRPCServer defines an endpoint of a gRPC service GRPCServer Endpoint // SwaggerDir is a path to a directory from which the server // serves swagger specs. SwaggerDir string // Mux is a list of options to be passed to the grpc-gateway multiplexer Mux []gwruntime.ServeMuxOption // 注册 Handles []regHandle }
Options is a set of options to be passed to Run
Click to show internal directories.
Click to hide internal directories.