Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithHeaderProcessor ¶
WithHeaderProcessor sets a processor to process request headers. The returned headers are used as metadata to invoke the RPC.
func WithMiddleware ¶ added in v1.9.0
func WithMiddleware(middlewares ...rest.Middleware) func(*Server)
WithMiddleware adds one or more middleware functions to process HTTP requests. Multiple middlewares will be executed in the order they were passed (like an onion model).
Types ¶
type GatewayConf ¶
GatewayConf is the configuration for gateway.
type HttpClientConf ¶ added in v1.8.0
type HttpClientConf struct {
Target string
Prefix string `json:",optional"`
Timeout int64 `json:",default=3000"`
}
HttpClientConf is the configuration for an HTTP client.
type RouteMapping ¶
type RouteMapping struct {
// Method is the HTTP method, like GET, POST, PUT, DELETE.
Method string
// Path is the HTTP path.
Path string
// RpcPath is the gRPC rpc method, with format of package.service/method, optional.
// If the mapping is for HTTP, it's not necessary.
RpcPath string `json:",optional"`
}
RouteMapping is a mapping between a gateway route and an upstream rpc method.
type Server ¶
Server is a gateway server.
func MustNewServer ¶
func MustNewServer(c GatewayConf, opts ...Option) *Server
MustNewServer creates a new gateway server.
type Upstream ¶
type Upstream struct {
// Name is the name of the upstream.
Name string `json:",optional"`
// Grpc is the target of the upstream.
Grpc *zrpc.RpcClientConf `json:",optional"`
// Http is the target of the upstream.
Http *HttpClientConf `json:",optional=!grpc"`
// ProtoSets is the file list of proto set, like [hello.pb].
// if your proto file import another proto file, you need to write multi-file slice,
// like [hello.pb, common.pb].
ProtoSets []string `json:",optional"`
// Mappings is the mapping between gateway routes and Upstream methods.
// Keep it blank if annotations are added in rpc methods.
Mappings []RouteMapping `json:",optional"`
}
Upstream is the configuration for an upstream.
Click to show internal directories.
Click to hide internal directories.