Are modules in nancyfx really created for every request?

I created a simple standalone Nancy site with a single module in a console project. During testing, I noticed that the module constructor is called for each request. This puzzles me, because ctor also logs routes. It doesn't make sense to me, and I have to miss something. This is the name of the module constructors that call for each request, and are all routes thus re-registered for each request?

+5
source share
1 answer

Sorting - Nancy will build all the modules at startup, register all their routes and build the Routing Tree. For each request, he will then find out which module he needs, and build it using the request container, so that the query-dependent scopes have the correct lifetime, and then performs the corresponding action. Routes are not "registered" for each request, they are simply stored in the collection in the module, and the engine performs the correct one.

+5
source

Source: https://habr.com/ru/post/1207866/


All Articles