- Add HTTP/2 transport support for gRPC calls - Implement dispatchGRPC to forward requests to Temporal gRPC server - Replace 501 Not Implemented with actual gRPC proxy - Use golang.org/x/net/http2 for HTTP/2 protocol support - Supports ListWorkflowExecutions and other gRPC methods
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/http2"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
|
||||
@@ -218,9 +219,33 @@ func (d *Dispatcher) dispatchGRPC(w http.ResponseWriter, r *http.Request, upstre
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
d.writeError(w, problem.NewProblem(http.StatusNotImplemented,
|
||||
"about:blank#not-implemented", "Not Implemented",
|
||||
"gRPC forwarding not yet implemented"))
|
||||
// Create HTTP/2 reverse proxy for gRPC
|
||||
// gRPC uses HTTP/2 protocol, so we need an HTTP/2-capable transport
|
||||
upstreamURLObj := &url.URL{
|
||||
Scheme: "http",
|
||||
Host: host,
|
||||
}
|
||||
|
||||
proxy := httputil.NewSingleHostReverseProxy(upstreamURLObj)
|
||||
proxy.Director = func(req *http.Request) {
|
||||
req.URL.Scheme = "http"
|
||||
req.URL.Host = host
|
||||
req.URL.Path = method.UpstreamPath
|
||||
req.RequestURI = ""
|
||||
req.Host = host
|
||||
}
|
||||
|
||||
// Create HTTP/2 client transport for gRPC calls
|
||||
// gRPC requires HTTP/2 for proper message framing
|
||||
h2transport := &http2.Transport{
|
||||
AllowHTTP: true,
|
||||
}
|
||||
|
||||
// Set the transport on the proxy
|
||||
proxy.Transport = h2transport
|
||||
|
||||
// Serve the request through the proxy
|
||||
proxy.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
func (d *Dispatcher) writeError(w http.ResponseWriter, p *problem.Problem) {
|
||||
|
||||
Reference in New Issue
Block a user