forked from slam-code/cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·34 lines (26 loc) · 728 Bytes
/
main.cpp
File metadata and controls
executable file
·34 lines (26 loc) · 728 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
#include <service.hpp>
#include <basic_server.hpp>
#include <string>
#include <iostream>
#include <functional>
#include <vector>
#include <memory>
#include <sstream>
#include <random>
using namespace cpplask;
int main() {
service_t s;
s.map<int>("/page/%") = [](request_t& req, auto x) {
req.response() << x;
};
s.map<int,int>("/page/%/%") = [](request_t& req, auto x, auto y) {
req.response() << x << " " << y;
};
s.map<std::string>("/title/%") = [](request_t& req, std::string) {
req.response() << req.headers("User-Agent");
};
s.map<path_t>("/file/%") = [](request_t& req, path_t path) {
serve_static_file(req, path);
};
basic_serve(s, 5000);
}