TrinityCore
HttpCommon.h
Go to the documentation of this file.
1
/*
2
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3
*
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by the
6
* Free Software Foundation; either version 2 of the License, or (at your
7
* option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License along
15
* with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef TRINITYCORE_HTTP_COMMON_H
19
#define TRINITYCORE_HTTP_COMMON_H
20
21
#include "
Define.h
"
22
#include <boost/beast/http/message.hpp>
23
#include <boost/beast/http/string_body.hpp>
24
25
namespace
Trinity::Net::Http
26
{
27
using
RequestBody
= boost::beast::http::string_body;
28
using
ResponseBody
= boost::beast::http::string_body;
29
30
using
Request
= boost::beast::http::request<RequestBody>;
31
using
Response
= boost::beast::http::response<ResponseBody>;
32
33
struct
RequestContext
34
{
35
Request
request
;
36
Response
response
;
37
struct
RequestHandler
const*
handler
=
nullptr
;
38
};
39
40
TC_SHARED_API
bool
CanLogRequestContent
(
RequestContext
const
& context);
41
TC_SHARED_API
bool
CanLogResponseContent
(
RequestContext
const
& context);
42
43
inline
std::string_view
ToStdStringView
(boost::beast::string_view bsw)
44
{
45
return
{ bsw.data(), bsw.size() };
46
}
47
48
enum class
RequestHandlerResult
49
{
50
Handled
,
51
Error
,
52
Async
,
53
};
54
}
55
#endif
// TRINITYCORE_HTTP_COMMON_H
Define.h
TC_SHARED_API
#define TC_SHARED_API
Definition:
Define.h:117
Trinity::Net::Http
Definition:
BaseHttpSocket.cpp:22
Trinity::Net::Http::ResponseBody
boost::beast::http::string_body ResponseBody
Definition:
HttpCommon.h:28
Trinity::Net::Http::Response
boost::beast::http::response< ResponseBody > Response
Definition:
HttpCommon.h:31
Trinity::Net::Http::ToStdStringView
std::string_view ToStdStringView(boost::beast::string_view bsw)
Definition:
HttpCommon.h:43
Trinity::Net::Http::RequestHandlerResult
RequestHandlerResult
Definition:
HttpCommon.h:49
Trinity::Net::Http::RequestHandlerResult::Async
@ Async
Trinity::Net::Http::RequestHandlerResult::Handled
@ Handled
Trinity::Net::Http::RequestBody
boost::beast::http::string_body RequestBody
Definition:
HttpCommon.h:27
Trinity::Net::Http::CanLogResponseContent
TC_SHARED_API bool CanLogResponseContent(RequestContext const &context)
Definition:
HttpService.cpp:33
Trinity::Net::Http::Request
boost::beast::http::request< RequestBody > Request
Definition:
HttpCommon.h:30
Trinity::Net::Http::CanLogRequestContent
TC_SHARED_API bool CanLogRequestContent(RequestContext const &context)
Definition:
HttpService.cpp:28
Trinity::Error
void Error(char const *file, int line, char const *function, char const *message)
Definition:
Errors.cpp:110
Trinity::Net::Http::RequestContext
Definition:
HttpCommon.h:34
Trinity::Net::Http::RequestContext::request
Request request
Definition:
HttpCommon.h:35
Trinity::Net::Http::RequestContext::response
Response response
Definition:
HttpCommon.h:36
Trinity::Net::Http::RequestContext::handler
struct RequestHandler const * handler
Definition:
HttpCommon.h:37
Trinity::Net::Http::RequestHandler
Definition:
HttpService.h:49
server
shared
Networking
Http
HttpCommon.h
Generated on Thu Mar 14 2024 23:39:35 for TrinityCore by
1.9.4