userver: /data/code/userver/libraries/easy/samples/1_hi/main.cpp Source File
Loading...
Searching...
No Matches
main.cpp
1#include <userver/utest/using_namespace_userver.hpp> // Note: this is for the purposes of samples only
2
3#include <userver/easy.hpp>
4
5std::string Greet(const server::http::HttpRequest& req) {
6 const auto& username = req.GetPathArg("user");
7 return "Hello, " + username;
8}
9
10struct Hi {
11 std::string operator()(const server::http::HttpRequest& req) const { return "Hi, " + req.GetArg("name"); }
12};
13
14int main(int argc, char* argv[]) {
15 easy::HttpWith<>(argc, argv)
16 .DefaultContentType(http::content_type::kTextPlain)
17 .Get("/hi/{user}", &Greet)
18 .Get("/hi", Hi{});
19}