zippera
V2EX  ›  问与答

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

  •  
  •   zippera · Jul 18, 2015 · 4910 views
    This topic created in 4041 days ago, the information mentioned may be changed or developed.
    例如:
    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 replies    2015-07-18 19:26:43 +08:00
    skydiver
        1
    skydiver  
       Jul 18, 2015
    关注。
    最近一直在找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
       Jul 18, 2015
    @skydiver nice。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5263 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 09:14 · PVG 17:14 · LAX 02:14 · JFK 05:14
    ♥ Do have faith in what you're doing.