RESTFUL API Server in C++
2016-05-26 17:24
806 查看
https://github.com/eidheim/Simple-Web-Server
See https://github.com/eidheim/Simple-WebSocket-Server for an easy way to make WebSocket/WebSocket Secure endpoints in C++. Also, feel free to check out the new C++ IDE supporting C++11/14/17:
https://github.com/cppit/jucipp.
Platform independent
HTTPS support
HTTP persistent connection (for HTTP/1.1)
Client supports chunked transfer encoding
Timeouts, if any of Server::timeout_request and Server::timeout_content are >0 (default: Server::timeout_request=5 seconds, and Server::timeout_content=300 seconds)
Simple way to add REST resources using regex for path, and anonymous functions
Possibility to flush response to clients synchronously (Server::Response::flush).
See particularly the JSON-POST (using Boost.PropertyTree) and the GET /match/[number] examples, which are most relevant.
The default_resource includes example use of Server::Response::flush.
For HTTPS: OpenSSL libraries
Direct your favorite browser to for instance http://localhost:8080/
http://www.akadia.com/services/ssh_test_certificate.html
Run the server and client examples:
Direct your favorite browser to for instance https://localhost:8080/
Simple-Web-Server
A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.See https://github.com/eidheim/Simple-WebSocket-Server for an easy way to make WebSocket/WebSocket Secure endpoints in C++. Also, feel free to check out the new C++ IDE supporting C++11/14/17:
https://github.com/cppit/jucipp.
Features
Thread poolPlatform independent
HTTPS support
HTTP persistent connection (for HTTP/1.1)
Client supports chunked transfer encoding
Timeouts, if any of Server::timeout_request and Server::timeout_content are >0 (default: Server::timeout_request=5 seconds, and Server::timeout_content=300 seconds)
Simple way to add REST resources using regex for path, and anonymous functions
Possibility to flush response to clients synchronously (Server::Response::flush).
Usage
See http_examples.cpp or https_examples.cpp for example usage.See particularly the JSON-POST (using Boost.PropertyTree) and the GET /match/[number] examples, which are most relevant.
The default_resource includes example use of Server::Response::flush.
Dependencies
Boost C++ librariesFor HTTPS: OpenSSL libraries
Compile and run
Compile with a C++11 compliant compiler:cmake . make
HTTP
Run the server and client examples:./http_examples
Direct your favorite browser to for instance http://localhost:8080/
HTTPS
Before running the server, an RSA private key (server.key) and an SSL certificate (server.crt) must be created. Follow, for instance, the instructions given here (for a self-signed certificate):http://www.akadia.com/services/ssh_test_certificate.html
Run the server and client examples:
./https_examples
Direct your favorite browser to for instance https://localhost:8080/
相关文章推荐
- 【C语言】03-第一个C程序代码分析
- c语言下的变量类型及计算
- C++ 面向对象 —— 实用程序片段
- 【C语言】02-第一个C程序
- C++模板类的使用
- 基于范围的 for 语句 (C++)
- c/c++强制类型转换
- \r \n 手札
- 【C语言】计算二维数组的边界元素之和
- 二叉树的先序、中序、后序遍历等基本操作c++实现
- 《C++ Concurrency in Action》读书笔记四 c++内存模型和原子类型
- c++ byte与int
- C指针操作——把ip字符串转换成ip range字符串
- 枚举
- 工作中重新封装编写的一系列工具函数(c/c++)
- c++中不区分大小写比较字符串大小
- C++中基类对象的引用
- C++11 多线程
- C++ REST SDK
- 再探指针