c# - Selectively disable certain REST Services in ServiceStack during runtime -


i want disable services programmatically. user can specify via configuration file if wants enable part of functionality, , if not, services should not exposed/created. know services disabled before creation of apphost.

now, use requestfilter check every time service run if actiavted, , if not, throw exception. imho unelegant solution, , swagger api docs still contain service should disabled.

any idea of how elegant way?

you can bundle services iplugin, have set routes manually. it's how things /metadata work.

public class myoptionalservicesplugin : iplugin {     public void register(iapphost apphost)     {          var settings = new appsettings();          var enablespecialservice1 = settings.get<bool>("enablespecialservice1", false);          if (enablespecialservice1)          {              apphost.registerservice(typeof(specialservice1), new[] { "/special/service-1" });          }           ...     }  } 

and in apphost:

public void register(funq.container container) {     plugins.add(new myoptionsservicesplugin());     ... } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -