0

I am using GRPc to send requests between clients and server.

I would like to add one software in between that gets requests once and redirect them to the server.

In get requests this is easy, we listen to requests and there is a redirect method that we can use to redirect the request to whatever URL we want.

example:

final Future<HttpServer> httpServer = 
    HttpServer.bind(InternetAddress.anyIPv4, 5004);
httpServer.then((server) {
  server.listen((HttpRequest request) async {
    request.response.redirect(Uri.parse('http://example.org'));
    request.response.close();
    (await httpServer).close();
  });
});

I would like to do the same thing with the GRPc stream.

GRPc is based on HTTP/2, here is an example of listening to GRPc request

final Future<ServerSocket> serverSocket =
    ServerSocket.bind(InternetAddress.anyIPv4, 5004);
serverSocket.then((server) {
  server.listen((Socket request) async {
    (await serverSocket).close();
  });
});

Is there a way to redirect HTTP/2 socket requests to a new destination?.

Guy Luz
  • 2,714
  • 14
  • 35

0 Answers0