Documentation ¶
Index ¶
- func Copy(src interface{}) interface{}
- func CopyByValue(original reflect.Value) interface{}
- func GetUserIdFromCtx(ctx context.Context) string
- func Iface(iface interface{}) interface{}
- func InterfaceToInt64(value interface{}) int64
- func WithHeaderProcessor(processHeader func(http.Header) []string) func(*Server)
- type Config
- type GatewayEngine
- func (e *GatewayEngine) DELETE(url string, handler interface{}, optionFs ...OptionFunc)
- func (e *GatewayEngine) GET(url string, handler interface{}, optionFs ...OptionFunc)
- func (e *GatewayEngine) Group(prefix string) (n *GatewayEngine)
- func (e *GatewayEngine) PATCH(url string, handler interface{}, optionFs ...OptionFunc)
- func (e *GatewayEngine) POST(url string, handler interface{}, optionFs ...OptionFunc)
- func (e *GatewayEngine) PUT(url string, handler interface{}, optionFs ...OptionFunc)
- func (e *GatewayEngine) Server(serverOptions ...rest.RunOption) *Server
- func (e *GatewayEngine) Upstreams() []upstream
- func (e *GatewayEngine) Use(middlewares ...rest.Middleware)
- type Handler
- type Interface
- type Option
- type OptionFunc
- type ResponseHandler
- type RouteMapping
- type Server
- type XResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Copy ¶
func Copy(src interface{}) interface{}
Copy creates a deep copy of whatever is passed to it and returns the copy in an interface{}. The returned value will need to be asserted to the correct type.
func CopyByValue ¶
func GetUserIdFromCtx ¶
func Iface ¶
func Iface(iface interface{}) interface{}
Iface is an alias to Copy; this exists for backwards compatibility reasons.
func InterfaceToInt64 ¶
func InterfaceToInt64(value interface{}) int64
Types ¶
type Config ¶
type Config struct { PbGroup string // 比如用户服务是 pb.userService RpcListenOn string // 比如用户服务是 :8080 CallRpcTimeoutSeconds int64 `json:",default=10"` Port int `json:",default=9000"` }
Config is the configuration for gateway.
type GatewayEngine ¶
type GatewayEngine struct { RestConf rest.RestConf Config Config ProtoSets [][]byte // contains filtered or unexported fields }
func Engine ¶
func Engine(serviceConf service.ServiceConf, conf Config, protoSets ...[]byte) *GatewayEngine
func (*GatewayEngine) DELETE ¶
func (e *GatewayEngine) DELETE(url string, handler interface{}, optionFs ...OptionFunc)
func (*GatewayEngine) GET ¶
func (e *GatewayEngine) GET(url string, handler interface{}, optionFs ...OptionFunc)
func (*GatewayEngine) Group ¶
func (e *GatewayEngine) Group(prefix string) (n *GatewayEngine)
func (*GatewayEngine) PATCH ¶
func (e *GatewayEngine) PATCH(url string, handler interface{}, optionFs ...OptionFunc)
func (*GatewayEngine) POST ¶
func (e *GatewayEngine) POST(url string, handler interface{}, optionFs ...OptionFunc)
func (*GatewayEngine) PUT ¶
func (e *GatewayEngine) PUT(url string, handler interface{}, optionFs ...OptionFunc)
func (*GatewayEngine) Server ¶
func (e *GatewayEngine) Server(serverOptions ...rest.RunOption) *Server
func (*GatewayEngine) Upstreams ¶
func (e *GatewayEngine) Upstreams() []upstream
func (*GatewayEngine) Use ¶
func (e *GatewayEngine) Use(middlewares ...rest.Middleware)
type Handler ¶
type Handler struct { *grpcurl.DefaultEventHandler // contains filtered or unexported fields }
func NewHandler ¶
func NewHandler(w http.ResponseWriter, source grpcurl.DescriptorSource, optionFs ...OptionFunc) *Handler
func (*Handler) OnReceiveResponse ¶
type Interface ¶
type Interface interface {
DeepCopy() interface{}
}
Interface for delegating copy process to type
type OptionFunc ¶
type OptionFunc func(*handlerOption)
func WithBuildHandler ¶
func WithBuildHandler(resp interface{}) OptionFunc
func WithResponseHandler ¶
func WithResponseHandler(responseHandler ResponseHandler) OptionFunc
type ResponseHandler ¶
func BuildHandler ¶
func BuildHandler(resp interface{}) ResponseHandler
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 RpcPath string // contains filtered or unexported fields }
RouteMapping is a mapping between a gateway route and an upstream rpc method.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.