C++ Web 框架,如 Java 的 spring
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6172567/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C++ web framework like spring for Java
提问by user775757
Is there any web framework in C++ which is like Spring for Java, i am currently working on an application which is in the web domain. Our existing applications are all developed in c++, and we are looking for some framework which has a small learning curve and provides exciting features. Has anyone come across such a framework. Please let me know.
C++ 中有没有类似于 Java 的 Spring 的 Web 框架,我目前正在开发一个位于 Web 域中的应用程序。我们现有的应用程序都是用 C++ 开发的,我们正在寻找一些学习曲线很小并提供令人兴奋的功能的框架。有没有人遇到过这样的框架。请告诉我。
采纳答案by user775757
回答by Suraj Chandran
If its DI you are looking for; Dependency injection in C++ is not really done a lot, because although you can inject a pointer in to a class, its not easy to say who's gonna free it. There is already a SO discussion here.
如果您正在寻找它的 DI;C++ 中的依赖注入并没有真正完成很多,因为虽然你可以将一个指针注入到一个类中,但很难说谁会释放它。这里已经有一个 SO讨论。
回答by Serge
回答by eprom
I think the opensource project 'Drogon' is what you want. Drogon can be found in github, Here's the descript of Drogon:
我认为开源项目“Drogon”就是你想要的。Drogon 可以在github中找到,这里是 Drogon 的描述:
Drogon is a C++14/14-based HTTP application framework. Drogon can be used to easily build various types of web application server programs using C++. Drogon's main application platform is Linux, it also supports Mac OS/UNIX. Its main features are as follows:
Drogon 是一个基于 C++14/14 的 HTTP 应用程序框架。Drogon 可用于使用 C++ 轻松构建各种类型的 Web 应用服务器程序。Drogon 的主要应用平台是 Linux,它也支持 Mac OS/UNIX。其主要特点如下:
- Use a non-blocking I/O network lib based on epoll (kqueue under MacOS/FreeBSD) to provide high-concurrency, high-performance network IO;
- Provide a completely asynchronous programming mode;
- Support Http1.0/1.1 (server side and client side);
- Based on template, a simple reflection mechanism is implemented to completely decouple the main program framework, controllers and views.
- Support cookies and built-in sessions;
- Support back-end rendering, the controller generates the data to the view to generate the Html page, the view is described by a "JSP-like" CSP file, the C++ code is embedded into the Html page by the CSP tag, and the drogon command-line tool automatically generates the C++ code file for compilation;
- Support view page dynamic loading (dynamic compilation and loading at runtime);
- Provide a convenient and flexible routing solution from the path to the controller handler;
- Support filter chains to facilitate the execution of unified logic (such as login verification, Http Method constraint verification, etc.) before controllers;
- Support https (based on OpenSSL);
- Support WebSocket (server side and client side);
- Support JSON format request and response, very friendly to the Restful API application development;
- Support file download and upload;
- Support gzip compression transmission;
- Support pipelining;
- Provide a lightweight command line tool, drogon_ctl, to simplify the creation of various classes in Drogon and the generation of view code;
- Support non-blocking I/O based asynchronously reading and writing database (PostgreSQL and MySQL(MariaDB) database);
- Support asynchronously reading and writing sqlite3 database based on thread pool;
- Support ARM Architecture;
- Provide a convenient lightweight ORM implementation that supports for regular object-to-database bidirectional mapping;
- Support plugins which can be installed by the configuration file at load time;
- Support AOP with build-in joinpoints.
- 使用基于epoll(MacOS/FreeBSD下的kqueue)的非阻塞I/O网络库,提供高并发、高性能的网络IO;
- 提供完全异步的编程模式;
- 支持Http1.0/1.1(服务端和客户端);
- 基于模板,实现了简单的反射机制,将主程序框架、控制器和视图完全解耦。
- 支持cookies和内置会话;
- 支持后端渲染,控制器生成数据到视图生成Html页面,视图由“类JSP”CSP文件描述,C++代码通过CSP标签嵌入Html页面, drogon命令行工具自动生成C++代码文件进行编译;
- 支持视图页面动态加载(动态编译和运行时加载);
- 提供从路径到控制器处理程序的方便灵活的路由解决方案;
- 支持过滤器链,方便在控制器之前执行统一逻辑(如登录验证、Http Method约束验证等);
- 支持https(基于OpenSSL);
- 支持WebSocket(服务器端和客户端);
- 支持JSON格式的请求和响应,对Restful API应用开发非常友好;
- 支持文件下载和上传;
- 支持gzip压缩传输;
- 支持流水线;
- 提供轻量级命令行工具drogon_ctl,简化Drogon中各种类的创建和视图代码的生成;
- 支持基于非阻塞 I/O 的异步读写数据库(PostgreSQL 和 MySQL(MariaDB) 数据库);
- 支持基于线程池异步读写sqlite3数据库;
- 支持ARM架构;
- 提供方便的轻量级 ORM 实现,支持常规的对象到数据库的双向映射;
- 支持加载时可以通过配置文件安装的插件;
- 支持带有内置连接点的 AOP。