Ram Argid
Ram Argid

Reputation: 253

ServiceStack Logical Separation of Procedures

I believe ServiceStack is a an exceptional framework that works well toward removing the plumbing that typically goes with web services, that said there is one deficiency that perhaps I just need clarification on.

When dealing with a large project, for example with multiple products, it seems like a logical separation is important. I understand how to separate security concerns and the like, but from a pure maintenance concern, team concern, and consumption concern it seems like I must be missing something.

It seems that something like:

api.domain.com/productA
api.domain.com/productB
api.domain.com/productC

are logical separations, and if you are just using the default documentation, assuming you have 150 procedures under each product (not to mention products D, E, F, and general services outside of any product) things could get a bit unwieldy.

So the question is: What is the best way to deal with and set up large projects like this. Does each one get its own appHost with an endpoint for that project/product? Is there another approach I'm not thinking of?

Upvotes: 2

Views: 58

Answers (1)

mythz
mythz

Reputation: 143359

The wiki docs on Modularizing ServiceStack shows how you can configure your Service implementation to spread across multiple dependencies, e.g:

public class AppHost : AppHostBase
{
    //Tell which assemblies to scan for services
    public AppHost() : base("My Product Services", 
       typeof(ServicesFromProductA).Assembly,
       typeof(ServicesFromProductB).Assembly
       /*, etc */) {}

    public override void Configure(Container container) {}
}

Your DTO's can also be spread across multiple dlls, although it's still recommended to keep your DTO assembly dependency-free.

Reverse Proxying / Url Rewriting to different ServiceStack instances

Another option that's worth considering depending on if there is a clean separation between your different products is to separate them into distinct Services and conceptually have them appear under the same url structure by using a reverse proxy or rewrite rules in IIS which will let you have different top-level paths mapped to different independent ServiceStack instances, e.g:

Upvotes: 2

Related Questions