-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
38 lines (25 loc) · 854 Bytes
/
main.cpp
File metadata and controls
38 lines (25 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <nodepp/nodepp.h>
#include <express/http.h>
using namespace nodepp;
void onMain() {
auto app = express::http::add();
app.USE([]( express_http_t cli, function_t<void> next ){
console::log( "this is a middleware" );
next();
});
app.GET("/test/:argument",[]( express_http_t cli ){
console::log( cli.params["argument"] );
cli.status(200)
.header( "content-type","text/plain" )
.send ( "this is an ExpressPP test" );
});
app.GET([]( express_http_t cli ){
cli.status(404)
.header( "content-type", "text/plain" )
.send ( "something went wrong" );
});
app.listen( "localhost", 8000, []( socket_t /*unused*/ ){
console::log( "server started at:" );
console::log( "http://localhost:8000" );
});
}