diff --git a/internal/serviceadapter/router.go b/internal/serviceadapter/router.go index 0ecf9cc..9d2e183 100644 --- a/internal/serviceadapter/router.go +++ b/internal/serviceadapter/router.go @@ -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) {