drogon
C++14/17-based HTTP application framework
Toggle main menu visibility
Loading...
Searching...
No Matches
Redirector.h
Go to the documentation of this file.
1
13
14
#pragma once
15
16
#include <
drogon/plugins/Plugin.h
>
17
#include <
drogon/HttpRequest.h
>
18
#include <vector>
19
20
namespace
drogon
21
{
22
namespace
plugin
23
{
31
using
RedirectorHandler
=
32
std::function<bool(
const
drogon::HttpRequestPtr &,
33
std::string &,
//"http://" or "https://"
34
std::string &,
// host
35
bool
&)>;
// path changed or not
43
using
PathRewriteHandler
= std::function<bool(
const
drogon::HttpRequestPtr &)>;
44
52
using
ForwardHandler
= std::function<void(
const
drogon::HttpRequestPtr &)>;
53
71
class
DROGON_EXPORT Redirector :
public
drogon::Plugin
<Redirector>,
72
public
std::enable_shared_from_this<Redirector>
73
{
74
public
:
75
Redirector()
76
{
77
}
78
79
void
initAndStart
(
const
Json::Value &config)
override
;
80
void
shutdown
()
override
;
81
82
void
registerRedirectHandler(
RedirectorHandler
&&handler)
83
{
84
handlers_.emplace_back(std::move(handler));
85
}
86
87
void
registerRedirectHandler(
const
RedirectorHandler
&handler)
88
{
89
handlers_.emplace_back(handler);
90
}
91
92
void
registerPathRewriteHandler(PathRewriteHandler &&handler)
93
{
94
pathRewriteHandlers_.emplace_back(std::move(handler));
95
}
96
97
void
registerPathRewriteHandler(
const
PathRewriteHandler &handler)
98
{
99
pathRewriteHandlers_.emplace_back(handler);
100
}
101
102
void
registerForwardHandler(ForwardHandler &&handler)
103
{
104
forwardHandlers_.emplace_back(std::move(handler));
105
}
106
107
void
registerForwardHandler(
const
ForwardHandler &handler)
108
{
109
forwardHandlers_.emplace_back(handler);
110
}
111
112
private
:
113
std::vector<RedirectorHandler> handlers_;
114
std::vector<PathRewriteHandler> pathRewriteHandlers_;
115
std::vector<ForwardHandler> forwardHandlers_;
116
};
117
118
}
// namespace plugin
119
}
// namespace drogon
HttpRequest.h
Plugin.h
drogon::plugin::PathRewriteHandler
std::function< bool(const drogon::HttpRequestPtr &)> PathRewriteHandler
The PathRewriteHandler is a function object that can be registered to the Redirector plugin....
Definition
Redirector.h:43
drogon::plugin::RedirectorHandler
std::function< bool(const drogon::HttpRequestPtr &, std::string &, std::string &, bool &)> RedirectorHandler
The RedirectorHandler is a function object that can be registered to the Redirector plugin....
Definition
Redirector.h:31
drogon::plugin::ForwardHandler
std::function< void(const drogon::HttpRequestPtr &)> ForwardHandler
The ForwardHandler is a function object that can be registered to the Redirector plugin....
Definition
Redirector.h:52
drogon::Plugin
The reflection base class for plugins.
Definition
Plugin.h:132
drogon::plugin::Redirector::shutdown
void shutdown() override
drogon::plugin::Redirector::initAndStart
void initAndStart(const Json::Value &config) override
drogon
Drogon Test is a minimal effort test framework developed because the major C++ test frameworks doesn'...
Definition
Attribute.h:23
lib
inc
drogon
plugins
Redirector.h
Generated by
1.17.0