Apache模块的RESTful服务 [英] Apache module for restful services

查看:137
本文介绍了Apache模块的RESTful服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是创建一个Apache模块,将提供RESTful服务(即,我们有一些遗留的code控制/查询一些网络设备,我们现在要公开该功能作为RESTful服务)。我猜可能流看起来是这样的:

My objective is create an apache module that will provide RESTful services (i.e., we have some legacy code that controls/queries some networking equipment and we would now like to expose that functionality as a RESTful service). I guess the flow might look something like this:

web浏览器 - 问题的RESTful URI ---> [阿帕奇(my_module)] - > ..
..--->接口,以现有的传统code。

WebBrowser -- issues RESTful URI---> [Apache (my_module) ] -->.. ..---> Interface to existing Legacy code.

我一直在摆弄各地的各种维客,博客,论坛,文章等,但我似乎无法理解这些REST风格的URL将如何得到(my_module)的阿帕奇[你可以告诉我从来没有与web的工作服务器内部,更不用说模块之前。我的意思是,我必须编辑httpd.conf文件,说是这样的:发送看起来像 HTTP的所有URL:// baseURL时/ restservices / ......到my_module。如果是这样,我怎么办呢?

I have been mucking around various wikis, blogs, forums, articles etc. but I just can't seem to understand how those RESTful urls will get to (my_module) in apache [you can tell I have never worked with web-servers internals, much less modules, before]. I mean, do I have to edit that httpd.conf file and say something like: Send all urls that look like http://baseurl/restservices/... to my_module. If so, how do I do it?

此外,什么会my_module实际获得?它是否得到完整的HTTP请求报文必须分析它像典型的CGI程序?

Also, what will my_module actually get? Does it get the full http request message and it has to parse it like typical CGI programs?

此外,什么是my_module与我的遗产code交互的最佳方法?例如,打开一个TCP连接,并发送邮件,写身边的遗产code包装国米preT的消息。或者,可以直接在my_module我的遗产code莫名其妙地调用函数,如果我编我的整个传统code作为一个Apache模块?

Further, what is the best way for my_module to interact with my legacy code? E.g., Open a TCP connection to it and send messages and write wrapper around legacy code to interpret those messages. Or can my_module directly invoke the functions in my legacy code somehow if I compiled my entire legacy code as a module in apache?

感谢您的任何提示。如果你知道一个好的教程,请点我给它。我在寻找一个高度概括,这将使我的架构(然后在我的开发者可以跟进具体细节)。

Thanks for any hints. If u know of a good tutorial, please point me to it. I'm looking for a high level overview that will give me the architecture (the developers under me can then follow up on the nitty-gritty details).

推荐答案

我会写的PHP或Python的扩展和使用mod_php的/ mod_wsgi的

我认为你是在错误的方式接近这一点:

I think you are approaching this in the wrong way:

Apache模块是不是真的要如何处理URL,如果你的要求是基本的报价。根据您的遗留code是在语言,我会建议:

Apache modules are not really how you want to handle a URL if your requirements are quote basic. Depending on the language your legacy code is in, I would advise:

绑定其API到蟒蛇 PHP 模块,并让该脚本通过正常手段的Apache调用。这也是很多简单的(在很多情况下),以胶水C-通话风格的编译语言,这些脚本语言,而不是Apache的本身。

Binding its API into a python or PHP module, and have that script called by Apache through normal means. It is also a lot simple (in many cases) to glue a C-call style compiled language to these scripting languages rather than Apache itself.

它也有增加一个抽象的,它允许你在你的核心遗产code脚本语言层额外的逻辑的优势。您可能还需要为 preprocess 数据,并交给它变成你的遗产code之前从请求验证。

It also has the advantage of adding an abstractions which allows you to layer additional logic in a scripting language on your core legacy code. You may also want to preprocess data and validate it from the request before handing it into your legacy code.

这两个PHP和Python也有基于REST的框架和工具。

Both PHP and Python also have RESTful frameworks and utilities.

如果你写一个Apache模块,然后查看用Perl编写Apache模块和ç

请参阅:
开发PHP扩展使用C ,的用C扩展Python或C ++ ......如果还使用Python签出WSGI的东西。

See: Developing PHP Extensions in C, Extending Python in C or C++ ... also if using Python checkout the WSGI stuff.

这篇关于Apache模块的RESTful服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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