userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
parse_status_code.hpp
Go to the documentation of this file.
1
#pragma once
2
6
7
#include <fmt/format.h>
8
9
#include <
userver/formats/common/meta.hpp
>
10
#include <
userver/formats/parse/to.hpp
>
11
#include <
userver/http/status_code.hpp
>
12
13
USERVER_NAMESPACE_BEGIN
14
15
namespace
http
{
16
18
template
<formats::common::IsFormatValue Value>
19
StatusCode
Parse(
const
Value& value,
formats::parse::To<StatusCode>
) {
20
using
IntType = std::underlying_type_t<StatusCode>;
21
constexpr
IntType kMinCode = 100;
22
constexpr
IntType kMaxCode = 599;
23
24
const
auto
integer = value.template As<IntType>();
25
if
(integer < kMinCode || integer > kMaxCode) {
26
throw
typename
Value::Exception(fmt::format(
27
"StatusCode value {} out of [{}..{}] range at '{}'"
,
28
integer,
29
kMinCode,
30
kMaxCode,
31
value.GetPath()
32
));
33
}
34
35
return
StatusCode
{integer};
36
}
37
38
}
// namespace http
39
40
USERVER_NAMESPACE_END
userver
http
parse_status_code.hpp
Generated on
for userver by
Doxygen
1.17.0