ServiceStack OrmLite with multiple APIs (private and public)

Viewed 28

We have a .net Core 3.1 MVC web application running with ServiceStack Ormlite 5.12. Currently we have a 'public' Open API for users who wish to access data programmatically. We use the following in our AppHost:

public class AppHost : AppHostBase
{

    public AppHost(IServiceProvider services, IWebHostEnvironment env)
        : base("My API", typeof(MyAPIService).Assembly)
    {
        _appServices = services;
        _env = env;
    }
    
    public override void Configure(Container container)
    {
        SetConfig(new HostConfig
        {
            ...
            HandlerFactoryPath = "/myapipath"
        });
        
        Plugins.Add(new OpenApiFeature
        {
            ...
        });
    }
}

And in our Web.config:

<configuration> 
      <location path="myapipath">
    <system.web>
      <httpHandlers>
        <add path="servicestack*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
      </httpHandlers>
    </system.web>
    <!-- Required for IIS7 -->
    <system.webServer>
      <modules runAllManagedModulesForAllRequests="true" />
      <validation validateIntegratedModeConfiguration="false" />
      <handlers>
        <add path="servicestack*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
      </handlers>
    </system.webServer>
  </location>
</configuration>

We have MyApp.ServiceModel and MyApp.ServiceInterface projects that are accessed from the https://{baseurl}/myapipath endpoint. This all works well so far.

We wish to keep the existing OpenAPI unchanged so that users don't need to change anything when updating to a new version. But we also want to add another API for use with an angular application, either by adding a separate endpoint for a 2nd API, or by filtering out what is visible in swagger with our existing API. Is it possible to add a 2nd API plugin with a different path that is separate from the existing API?

1 Answers
Related