ServiceStack: dynamically add routes

I have not tried this yet, but I would like each module (Silverlight) to register its own routes, and then add it to the top of the application.

Is it possible to add routes to AppHost after launching the application, or should all of them be registered immediately during the setup phase?

I'm going to scan all the assemblies at startup and provide AppHost with all the assemblies that implement the service stack services, but let each module add its own routes (I have not figured out the exact mechanism yet.

Before you go along this route, you need to know whether it is possible to add routes after the configuration step.

+5
source share
1 answer

ServiceStack AppHost.Configure() .

, , Plugin IPlugin.Register(IAppHost).

:

public class MyModule : IPlugin
{
    public void Register(IAppHost appHost)
    {
        appHost.Routes.Add<MyRequestDto>("/myservice", "POST PUT");

        appHost.Routes.Add(typeof(MyRequestDto2), "/myservice2", "GET");

        appHost.RegisterService(typeof(MyService), "/myservice3"); 
    }
}

AppHost.Configure , :

Plugins.Add(new MyModule());
+5

All Articles