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)
|
m := cmux.New(ln)
|
||||||
|
|
||||||
rpcxLn := m.Match(rpcxPrefixByteMatcher())
|
rpcxLn := m.Match(rpcxPrefixByteMatcher())
|
||||||
jsonrpc2Ln := m.Match(cmux.HTTP1HeaderField("X-JSONRPC-2.0", "true"))
|
|
||||||
httpLn := m.Match(cmux.HTTP1Fast())
|
|
||||||
|
|
||||||
go s.startJSONRPC2(jsonrpc2Ln)
|
if !s.DisableJSONRPC {
|
||||||
go s.startHTTP1APIGateway(httpLn)
|
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()
|
go m.Serve()
|
||||||
|
|
||||||
return rpcxLn
|
return rpcxLn
|
||||||
|
@@ -59,10 +59,12 @@ var (
|
|||||||
|
|
||||||
// Server is rpcx server that use TCP or UDP.
|
// Server is rpcx server that use TCP or UDP.
|
||||||
type Server struct {
|
type Server struct {
|
||||||
ln net.Listener
|
ln net.Listener
|
||||||
readTimeout time.Duration
|
readTimeout time.Duration
|
||||||
writeTimeout time.Duration
|
writeTimeout time.Duration
|
||||||
gatewayHTTPServer *http.Server
|
gatewayHTTPServer *http.Server
|
||||||
|
DisableHTTPGateway bool // should disable http invoke or not.
|
||||||
|
DisableJSONRPC bool // should disable json rpc or not.
|
||||||
|
|
||||||
serviceMapMu sync.RWMutex
|
serviceMapMu sync.RWMutex
|
||||||
serviceMap map[string]*service
|
serviceMap map[string]*service
|
||||||
|
Reference in New Issue
Block a user