https://github.com/beached/lib_nodepp
NodePP library
https://github.com/beached/lib_nodepp
cpp event-driven networking
Last synced: about 1 year ago
JSON representation
NodePP library
- Host: GitHub
- URL: https://github.com/beached/lib_nodepp
- Owner: beached
- License: mit
- Created: 2016-05-06T01:31:53.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2019-09-23T03:27:16.000Z (over 6 years ago)
- Last Synced: 2025-01-07T21:12:32.718Z (over 1 year ago)
- Topics: cpp, event-driven, networking
- Language: C++
- Size: 708 KB
- Stars: 0
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
A high level library to let me do asynchronous c++ programming like that done in Node.js.
```C++
#include
#include "base_work_queue.h"
#include "lib_http_request.h"
#include "lib_http_site.h"
#include "lib_http_static_service.h"
int main( int argc, char const **argv ) {
using namespace daw::nodepp;
using namespace daw::nodepp::lib::net;
using namespace daw::nodepp::lib::http;
auto site = create_http_site( );
site->on_listening( []( EndPoint endpoint ) {
std::cout << "Node++ Static HTTP Server\n";
std::cout << "Listening on " << endpoint << '\n';
} )
.on_error( []( base::Error error ) {
std::cerr << "Error: ";
std::cerr << error << '\n';
} )
.listen_on( 8080 );
auto service = create_static_service( "/", "./web_files" );
service->connect( site );
base::start_service( base::StartServiceMode::OnePerCore );
return EXIT_SUCCESS;
}
```
As you can see, one can create a static web server quickly and succinctly. Currently, the library focus is on networking and HTTP networking. Other async tasks will be added, such as Sqlite support as I need them. The tests folder contains more examples.