当 URL 导航到(从 Meteor 内部)时,关于请求者的哪些信息可用?

What information about the requester is available when an URL is navigated to (from within Meteor)?

如果用户导航到您的 Meteor 应用程序中的 URL,例如 "platypus.meteor.com/nfnoscar",是否有一个事件可以读取有关用户设备的信息,例如通过 HttpRequest 对象或其他东西?

IOW,当 URL 被导航到时,关于请求者上下文的信息是什么(如果有的话)?可以读取请求设备的功能吗?有什么吗?

更新

我试图用这段代码来测试 MasterAM 的想法:

Template.garrapatabeach.rendered = function() {
   var req = request;
   alert(req);
}

...但我得到:

=> Exited with code: 8
. . .
W20151012-09:48:06.548(-7)? (STDERR) ReferenceError: Template is not defined
W20151012-09:48:06.549(-7)? (STDERR)     at meatier.js:8:1

meatier.js 第 8 行是:

Template.garrapatabeach.rendered = function() {

我有一个同名的模板:

<template name="garrapatabeach">

...所以我不知道抱怨是什么...当然它知道 "Template" 本身是什么。为了全面披露,这里是错误的整个控制台转储:

=> Exited with code: 8
W20151012-09:48:06.543(-7)? (STDERR)
W20151012-09:48:06.547(-7)? (STDERR) C:\Users\clayshan\AppData\Local\.meteor\pac
kages\meteor-tool.1.9\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\
fibers\future.js:245
W20151012-09:48:06.547(-7)? (STDERR)
throw(ex);
W20151012-09:48:06.548(-7)? (STDERR)
      ^
W20151012-09:48:06.548(-7)? (STDERR) ReferenceError: Template is not defined
W20151012-09:48:06.549(-7)? (STDERR)     at meatier.js:8:1
W20151012-09:48:06.549(-7)? (STDERR)     at C:\Misc\meatier\.meteor\local\build\
programs\server\app\meatier.js:32:4
W20151012-09:48:06.550(-7)? (STDERR)     at C:\Misc\meatier\.meteor\local\build\
programs\server\boot.js:242:10
W20151012-09:48:06.550(-7)? (STDERR)     at Array.forEach (native)
W20151012-09:48:06.550(-7)? (STDERR)     at Function._.each._.forEach (C:\Users\
clayshan\AppData\Local\.meteor\packages\meteor-tool.1.9\mt-os.windows.x86_32\d
ev_bundle\server-lib\node_modules\underscore\underscore.js:79:11)
W20151012-09:48:06.551(-7)? (STDERR)     at C:\Misc\meatier\.meteor\local\build\
programs\server\boot.js:137:5
W20151012-09:48:23.969(-7)? (STDERR)
W20151012-09:48:23.970(-7)? (STDERR) C:\Users\clayshan\AppData\Local\.meteor\pac
kages\meteor-tool.1.9\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\
fibers\future.js:245
W20151012-09:48:23.971(-7)? (STDERR)
throw(ex);
W20151012-09:48:23.971(-7)? (STDERR)
      ^
W20151012-09:48:23.971(-7)? (STDERR) ReferenceError: Template is not defined
W20151012-09:48:23.972(-7)? (STDERR)     at meatier.js:8:1
W20151012-09:48:23.972(-7)? (STDERR)     at C:\Misc\meatier\.meteor\local\build\
programs\server\app\meatier.js:32:4
W20151012-09:48:23.972(-7)? (STDERR)     at C:\Misc\meatier\.meteor\local\build\
programs\server\boot.js:242:10
W20151012-09:48:23.973(-7)? (STDERR)     at Array.forEach (native)
W20151012-09:48:23.973(-7)? (STDERR)     at Function._.each._.forEach (C:\Users\
clayshan\AppData\Local\.meteor\packages\meteor-tool.1.9\mt-os.windows.x86_32\d
ev_bundle\server-lib\node_modules\underscore\underscore.js:79:11)
W20151012-09:48:23.973(-7)? (STDERR)     at C:\Misc\meatier\.meteor\local\build\
programs\server\boot.js:137:5

使用 webapp package 您可以访问 Meteor 的 HTTP 连接处理程序。
您可以将自己的逻辑挂接到连接处理程序:

WebApp.rawConnectHandlers.use('/somepath', (req, res, next) => {
  console.log(`received request with headers : ${req.headers}`)
  next()
})

文档做广告connectHandlers但我永远做不到这些!
查看更多关于 arrow functions and Template Strings ES2015 magic

per the docs the first argument to the callback is a NodeJS HTTP Incoming message and the second argument is obviously a NodeJS HTTP Server Response。第三个参数是完成后必须调用的函数,各种路由器技术使用类似的策略(iron:router、ExpressJS、...)。

由于您可以访问原始请求,因此您可以访问 Node 提供给您的所有信息(主机、用户代理等),并且您可以更改对 的响应。

为了实现这一点,我建议通过 package approach 来确保这些连接处理程序的更改在您需要的时候发生,在您的应用程序加载之前。
它还允许您在任何地方重复使用它。

最后,请注意 webapp 软件包本质上只能在服务器上使用。