scottoffen / grapevine-legacy

Embedding A REST Server In Your Application Should Be Simple
http://scottoffen.github.io/grapevine-legacy/
Apache License 2.0
209 stars 51 forks source link

[Improvement] add flag to prevent automatic assembly scanning #199

Closed Xyolyp closed 3 years ago

Xyolyp commented 6 years ago

In my project I work with thousands of assemblies and the scanning takes forever. I currently pervent it by registering a transparent route at "/" before starting the router. It would be nice if there was a build in way to prevent the scanning of assemlies in a way that doesn't require any unnecessary routes.

scottoffen commented 3 years ago

Grapevine 5 offers two potential solutions. Both involve adding a BeforeStarting event handler. In the handler you can either:

  1. Get the routes you want to register using IRestServer.RouteScanner.ScanAssemblyContainingType<T>(), and then register them using IRestServer.Router.Register(IEnumerable<IRoute> routes)
  2. Add the assemblies you don't want scanned to the route scanner ignore list using IRestServer.RouteScanner.AddIgnoredAssembly(string assemblyName)

Whichever way works best for your scenario.