-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouting.cpp
More file actions
38 lines (38 loc) · 714 Bytes
/
routing.cpp
File metadata and controls
38 lines (38 loc) · 714 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 <bserv/common.hpp>
#include <boost/json.hpp>
#include <string>
boost::json::object greet(
const std::string& name)
{
return {{"hello", name}};
}
boost::json::object greet2(
const std::string& name1,
const std::string& name2)
{
return {
{"name1", name1},
{"name2", name2}
};
}
boost::json::object echo(
boost::json::object&& params)
{
return params;
}
int main()
{
bserv::server_config config;
bserv::server{config, {
bserv::make_path(
"/greet/<str>", &greet,
bserv::placeholders::_1),
bserv::make_path(
"/greet/<str>/and/<str>", &greet2,
bserv::placeholders::_1,
bserv::placeholders::_2),
bserv::make_path(
"/echo", &echo,
bserv::placeholders::json_params)
}};
}