南希:我怎么捕获所有请求,不论动词或路径 [英] Nancy: how do I capture all requests irrespective of verb or path

查看:137
本文介绍了南希:我怎么捕获所有请求,不论动词或路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用南希用默认的路由,它的清洁和工作得很好,但是我想一个选项,不论登录是否一个显式路由的所有传入的请求到控制台(我使用的是南希的自托管模块)存在。简单地说,我希望能够捕捉到动词,传入的请求URI,任何发布的数据(如果它是一个POST请求)等。

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.

我该怎么办这个? 之前 / 似乎只为匹配现有的路由请求运行,404不会触发的OnError 无论是。此外,使用获取[/(.*)\"]只捕获GET请求,并会忽略其他HTTP动词。

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.

推荐答案

使用之前 / 上的应用层面,不模块,对于 https://github.com/NancyFx/Nancy /维基/的-应用程序之前%2C-后和-的OnError-管道

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

这篇关于南希:我怎么捕获所有请求,不论动词或路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆