userver
C++ Async Framework
Loading...
Searching...
No Matches
user_env.hpp
1
#
pragma
once
2
3
#
include
<
stdexcept
>
4
#
include
<
string
>
5
6
#
include
<
userver
/
formats
/
parse
/
to
.
hpp
>
7
#
include
<
userver
/
utils
/
assert
.
hpp
>
8
9
USERVER_NAMESPACE_BEGIN
10
11
namespace
server::handlers::auth {
12
class
AuthCheckerBase
;
13
}
14
15
namespace
server::auth {
16
17
/// @brief Authorization environments for users
18
enum
class
UserEnv :
int
{
19
kProd,
20
kTest,
21
kProdYateam,
22
kTestYateam,
23
kStress,
24
};
25
26
template
<
class
Value>
27
UserEnv Parse(
const
Value& v,
formats
::
parse
::
To
<UserEnv>) {
28
const
std::string env_name = v.
template
As<std::string>();
29
if
(env_name ==
"Prod"
|| env_name ==
"Mimino"
) {
30
return
UserEnv::kProd;
31
}
else
if
(env_name ==
"Test"
) {
32
return
UserEnv::kTest;
33
}
else
if
(env_name ==
"ProdYateam"
) {
34
return
UserEnv::kProdYateam;
35
}
else
if
(env_name ==
"TestYateam"
) {
36
return
UserEnv::kTestYateam;
37
}
else
if
(env_name ==
"Stress"
) {
38
return
UserEnv::kStress;
39
}
40
41
UASSERT_MSG
(
false
,
"Unknown user env"
);
42
throw
std::runtime_error(
"Unknown user env "
+ env_name);
43
}
44
45
std::string ToString(UserEnv env);
46
47
}
// namespace server::auth
48
49
USERVER_NAMESPACE_END
userver
server
auth
user_env.hpp
Generated on Wed Dec 4 2024 18:45:39 for userver by
Doxygen
1.10.0