在Azure上的IISNode调用本地主机的网址 [英] Calling localhost urls on Azure's IISNode

查看:115
本文介绍了在Azure上的IISNode调用本地主机的网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一些问题上,由于IISNode Azure中运行的网站已节点的应用程序。基本上,这个问题是我依靠的端口号是一个数字,坦率地说是不是在Azure上的情况下......这里的端口号实际上是一个命名管道,并拥有价值如 \\\\。 \\管\\ 76deda07-ef5c-4539-87d8-755ede772521 。因此,下面的一段code,哪些路由内部请求返回到本地主机上定义的HTTP路线,不工作的:

I am running into some issues with running a Node app on Azure WebSites due to IISNode. Basically the issue is that I am relying on the port number being a number, which frankly is not the case on Azure ... Here the port number is actually a named pipe, and has values like \\.\pipe\76deda07-ef5c-4539-87d8-755ede772521. Thus, the following piece of code, which routes an internal request back onto the HTTP routes defined on localhost, does not work:

function getFromLocalRoute(restPayloadObject, callback) {

    request.get({
        uri : util.format('http://localhost:%s/api/%s', app.config.port, restPayloadObject.servicepath),
        json : true
    }, callback);
}

应该不用说,这个工程对* nix系统很好,但现在我需要找到处理这个在Windows上运行,以及一个不错的方式。

It should go without saying that this works fine on *nix systems, but now I need to find a nice way of handling this that works on Windows as well.

什么,我基本上以后是这样的:
 1.我有一个在本地主机上存在一个url
 2.我想用这个URL来调用本地主机上的网址
 3.必须努力用IISNode

What I am after is basically this: 1. I have a url that exists on localhost 2. I would like to call the url on localhost using this url 3. It must work using IISNode

它不必使用HTTP。我只是想重用通过使用防爆preSS来处理我的路由逻辑,分析一切,将其发送到正确的模块等,所以,如果有呼叫前preSS的方式隐含逻辑路由器在不使用HTTP这将是完美的。

It does not have to use HTTP. I simply want to reuse the logic that is implicit by using Express to handle my routing logic, parsing everything, sending it on to the right modules, etc. So if there is a way of calling the Express Router without using HTTP that would be perfect.

相关阅读:

  • Node HTTP request using a named pipe
  • Possible to call Express Router directly from code with a "fake" request?

推荐答案

我发布<一个href=\"http://stackoverflow.com/questions/33090091/is-it-possible-to-call-ex$p$pss-router-directly-from-$c$c-with-a-fake-request\">another 的问题涉及到这个问题,我发现适用于这个问题一个体面的编程解决方案。

I posted another question that was related to this problem, and I found a decent programmatic solution that applies to this problem.

原来这是可以调用前press.Router 直接使用(非公开/非官方)路由器#手柄方法用一个掐灭请求和响应的对象。关于这种方法的详细信息,您可以参阅这个答案

Turns out it is possible to call express.Router directly by using the (non-public/unofficial) Router#handle method with a stubbed out request and response object. For details on that approach you can refer to this answer.

原来的命名管道的做法是不可行的,因此调用路由器直接看起来最接近适合手头的问题。

It turned out that the named pipe approach was non-viable, so calling the Router directly seems like the closest fit for the problem at hand.

这篇关于在Azure上的IISNode调用本地主机的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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