mirror of
https://github.com/smallnest/rpcx.git
synced 2025-10-20 14:55:16 +08:00
add 2 options to control httpinvoke and jsonrpc 2.0 services
This commit is contained in:
@@ -27,11 +27,17 @@ func (s *Server) startGateway(network string, ln net.Listener) net.Listener {
|
||||
m := cmux.New(ln)
|
||||
|
||||
rpcxLn := m.Match(rpcxPrefixByteMatcher())
|
||||
jsonrpc2Ln := m.Match(cmux.HTTP1HeaderField("X-JSONRPC-2.0", "true"))
|
||||
httpLn := m.Match(cmux.HTTP1Fast())
|
||||
|
||||
go s.startJSONRPC2(jsonrpc2Ln)
|
||||
go s.startHTTP1APIGateway(httpLn)
|
||||
if !s.DisableJSONRPC {
|
||||
jsonrpc2Ln := m.Match(cmux.HTTP1HeaderField("X-JSONRPC-2.0", "true"))
|
||||
go s.startJSONRPC2(jsonrpc2Ln)
|
||||
}
|
||||
|
||||
if !s.DisableHTTPGateway {
|
||||
httpLn := m.Match(cmux.HTTP1Fast())
|
||||
go s.startHTTP1APIGateway(httpLn)
|
||||
}
|
||||
|
||||
go m.Serve()
|
||||
|
||||
return rpcxLn
|
||||
|
@@ -59,10 +59,12 @@ var (
|
||||
|
||||
// Server is rpcx server that use TCP or UDP.
|
||||
type Server struct {
|
||||
ln net.Listener
|
||||
readTimeout time.Duration
|
||||
writeTimeout time.Duration
|
||||
gatewayHTTPServer *http.Server
|
||||
ln net.Listener
|
||||
readTimeout time.Duration
|
||||
writeTimeout time.Duration
|
||||
gatewayHTTPServer *http.Server
|
||||
DisableHTTPGateway bool // should disable http invoke or not.
|
||||
DisableJSONRPC bool // should disable json rpc or not.
|
||||
|
||||
serviceMapMu sync.RWMutex
|
||||
serviceMap map[string]*service
|
||||
|
Reference in New Issue
Block a user