7#include <userver/formats/common/meta.hpp>
8#include <userver/formats/parse/to.hpp>
9#include <userver/http/status_code.hpp>
11USERVER_NAMESPACE_BEGIN
15template <
typename Value,
typename = std::enable_if_t<formats::common::kIsFormatValue<Value>>>
17 using IntType = std::underlying_type_t<StatusCode>;
18 constexpr IntType kMinCode = 100;
19 constexpr IntType kMaxCode = 599;
21 const auto integer = value.
template As<IntType>();
22 if (integer < kMinCode || integer > kMaxCode) {
23 throw typename Value::Exception(fmt::format(
24 "StatusCode value {} out of [{}..{}] range at '{}'", integer, kMinCode, kMaxCode, value.GetPath()
28 return StatusCode{integer};