Example of a Service or Rest Gateway

I would like to create an internal API Gateway, which passes calls to external CRUD REST endpoints. Is there an example of a best practice for doing this this using the latest 5.9 release?

For instance, I am not sure whether I am supposed to use IRestGateway, IServiceGateway or the ProxyFeature.

All pointers appreciated.

If you just want to pass/proxy all external requests through a single Server you may want to handle it with system software by using the reverse proxying features of popular Web Servers:

If you’d prefer these requests were routed through your .NET App (e.g. an App-level proxy) you can use the ProxyFeature plugin or Microsoft’s new reverse proxy:

If you’re just proxying ServiceStack requests and you want to be able to intercept the Request DTOs in C# I’d recommend using the IServiceGateway which will give you the most flexibility in which configured Service Client gets used to send the request, e.g:

public override void Configure(Container container)
  container.Register<IServiceGateway>(c => new JsonServiceClient(externalBaseUrl));

public class ProxyServices : Service
    public Task<object> Any(MyRequest1 request) => Gateway.SendAsync(request);
    public Task<object> Any(MyRequest2 request) => Gateway.SendAsync(request);

If you annotate your Request DTOs with HTTP Verb Interface Markers then you can use Any to Send every Request DTO and it will be sent with that HTTP Method.