Hi every body
i have suggestion for routing gRPC requests in V2.0
i reported it as issue
Please check it.
Thanks in advance.
can route gRPC request for variable urls
for instance :
example.com/service1 for invoke service1
example.com/service2 for invoke service2
in current implementation for example this proto
syntax = "proto3";
option java_multiple_files = true;
option java_package = "io.grpc.examples.helloworld";
option java_outer_classname = "HelloWorldProto";
option objc_class_prefix = "HLW";
package helloworld;
// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply) {}
}
// The request message containing the user's name.
message HelloRequest {
string name = 1;
}
// The response message containing the greetings
message HelloReply {
string message = 1;
}
its better to be called by url: example.com/v1/greaters/hello_world
For this proto every request will have attributes like :
host: example.com/hello/world
url path : /helloworld.Greeter/SayHello
as in docs available matchers for this scenario are
- host, HostRegexp
- Path, PathPrefix
HostRegexp can be used for segregate urls but there is a problem with this approach.
traefik use containous fork on gorilla/mux and in
pkg/mod/github.com/containous/mux@v0.0.0-20181024131434-c33f32e26898/regexp.go:308
// getHost tries its best to return the request host.
func getHost(r *http.Request) string {
if r.URL.IsAbs() {
return r.URL.Host
}
host := r.Host
// Slice off any port information.
if i := strings.Index(host, ":"); i != -1 {
host = host[:i]
}
return host
}
urls after colon : will be truncated before check regexp.
My suggestion is use other option for check whole url for routing rule.
something like grpc url or just Url and UrlRegexP.
BTW: In gRPC request host variable holds host and path and name Host for url is somehow misleading.