V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
zippera
V2EX  ›  问与答

怎样为 C/C++ 程序提供 REST API?

  •  
  •   zippera · 2015-07-18 12:36:07 +08:00 · 4402 次点击
    这是一个创建于 3217 天前的主题,其中的信息可能已经有所发展或是发生改变。
    例如:
    face++: http://www.faceplusplus.com.cn/api-overview/

    有些核心服务需要用 C/C++ 写,然后提供 REST API 给别人用。目前我知道的方案有:

    1. Apache/Nginx + FastCGI, 缺点是 C 代码处理 request response 还是需要一些代码量的,而且对复杂 url 的 route 不知道怎么做
    2. Web server + Python/PHP + C/C++
    3. 自己用socket实现一个 http server: https://github.com/yanyiwu/cppjieba 就是用自己写的 server 提供的 web 服务


    像 百度之类的大公司,很多服务的后端和引擎都是用 c/c++ 写的,它们也提供了 REST API, 我想知道一般都用什么方案实现
    2 条回复    2015-07-18 19:26:43 +08:00
    skydiver
        1
    skydiver  
       2015-07-18 13:19:44 +08:00
    关注。
    最近一直在找C++的httpserver实现。目前觉得libevent自带的http看着不错。
    另外github上发现了一些人写的实现,具体稳定性未知。列在这儿吧。
    https://github.com/d5/node.native
    https://github.com/eidheim/Simple-Web-Server
    https://github.com/jorisvink/kore
    http://cppcms.com/
    https://github.com/ipkn/crow
    zippera
        2
    zippera  
    OP
       2015-07-18 19:26:43 +08:00
    @skydiver nice。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   6262 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 01:58 · PVG 09:58 · LAX 18:58 · JFK 21:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.