summaryrefslogtreecommitdiffstats
path: root/server/src/problem.cppm
blob: 18c2fe21b78c611ffacf36cb288ada4a203c12f4 (about) (plain) (blame)
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
39
40
41
42
43
module;

#include <boost/beast/http/message.hpp>
#include <boost/json.hpp>
#include <boost/locale/message.hpp>

export module routemon:problem;

import std;
import :locale;

namespace http = boost::beast::http;
namespace json = boost::json;

namespace routemon::problem {

export struct details
{
  http::status status;
  blocale::message title;
  std::string_view type_uri;
  std::optional<blocale::message> detail = std::nullopt;
  std::optional<std::string> instance = std::nullopt;

  auto set_detail(blocale::message detail) -> details&;
  auto set_instance(std::string&& instance) -> details&;
  auto set_instance(std::string_view instance) -> details&;
};

auto tag_invoke(
    json::value_from_tag, json::value& jv, details const& details,
    std::locale locale) -> void;

export struct tpl
{
  http::status status;
  blocale::message title;
  std::string_view type_uri;

  auto instantiate() const -> details;
};

} // namespace routemon::problem