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

泪湿孤枕 提交于 2019-12-10 02:12:03

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/17591494/nancy-how-do-i-capture-all-requests-irrespective-of-verb-or-path

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!