-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
ConsulService discovery by ConsulService discovery by ConsulDependency InjectionOcelot feature: Dependency InjectionOcelot feature: Dependency InjectionService DiscoveryOcelot feature: Service DiscoveryOcelot feature: Service DiscoveryacceptedBug or feature would be accepted as a PR or is being worked onBug or feature would be accepted as a PR or is being worked on
Description
Hello,
At the moment service name is chosen based on first segment in the path.
I would like to be able to map one (or multiple) path segments to service name in Consul.
Few examples:
authorization
=> would mapped to authorization.service.web
authorization/api
=> would be mapped to authorization.service.api
Reason for this, that my routes are defined in Consul tags and I would like to use them as a key when selecting service name in Consul.
At the moment to achieve this I have to replace whole DownstreamRouteCreator
class, while I would be keen to keep custom part as small as possible.
Would you mind if I make a PR for this?
So something like:
public interface IServiceNameProvider
{
string GetServiceName(string upstreamUrlPath);
}
public class ServiceNameProvider: IServiceNameProvider
{
public string GetServiceName(string upstreamUrlPath)
{
if (upstreamUrlPath.IndexOf('/', 1) == -1)
{
return upstreamUrlPath
.Substring(1);
}
return upstreamUrlPath
.Substring(1, upstreamUrlPath.IndexOf('/', 1))
.TrimEnd('/');
}
}
and use this such provider in CustomDownstreamRouteCreator
class.
with best regards
Metadata
Metadata
Assignees
Labels
ConsulService discovery by ConsulService discovery by ConsulDependency InjectionOcelot feature: Dependency InjectionOcelot feature: Dependency InjectionService DiscoveryOcelot feature: Service DiscoveryOcelot feature: Service DiscoveryacceptedBug or feature would be accepted as a PR or is being worked onBug or feature would be accepted as a PR or is being worked on