Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nancy: how do I capture all requests irrespective of verb or path

Tags:

c#

nancy

I want to use Nancy with the default routing, as it's clean and works well, however I want an option to log all incoming requests to the console (I'm using Nancy's self-hosting module) irrespective of whether an explicit route exists. Put simply, I want to be able to capture the verb, the incoming request URI, any posted data (if it's a POST request), etc.

How do I do this? Before/After only seem to run for requests that match an existing route, and a 404 does not trigger OnError either. Also, using Get["/(.*)"] only catches GET requests and will ignore other HTTP verbs.

like image 963
Nathan Ridley Avatar asked Jul 11 '13 10:07

Nathan Ridley


1 Answers

Use the Before/After on an Application level, not Module, for that https://github.com/NancyFx/Nancy/wiki/The-Application-Before%2C-After-and-OnError-pipelines

like image 117
TheCodeJunkie Avatar answered Oct 20 '22 02:10

TheCodeJunkie