blob: 11d18e8f2e6480d14ef2b7a1ce8035f87e40bc9c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#include "irouteHandler.h"
#include "core.h"
#include <plugins.impl.h>
INSTANTIATEPLUGINOF(IceSpider::IRouteHandler);
namespace IceSpider {
IRouteHandler::IRouteHandler(HttpMethod m, const std::string & p) :
Path(p),
method(m)
{
}
void
IRouteHandler::initialize()
{
auto globalSerializers = AdHoc::PluginManager::getDefault()->getAll<Slicer::StreamSerializerFactory>();
for (const auto & gs : globalSerializers) {
auto slash = gs->name.find('/');
routeSerializers.insert({ { gs->name.substr(0, slash), gs->name.substr(slash + 1) }, gs });
}
}
Ice::ObjectPrx
IRouteHandler::getProxy(IHttpRequest * request, const char * type) const
{
return request->core->getProxy(type);
}
Slicer::SerializerPtr
IRouteHandler::getSerializer(const char * grp, const char * type, std::ostream & strm) const
{
for (const auto & rs : routeSerializers) {
if ((!grp || rs.first.first == grp) && (!type || rs.first.second == type)) {
return rs.second->implementation()->create(strm);
}
}
return nullptr;
}
Slicer::SerializerPtr
IRouteHandler::defaultSerializer(std::ostream & strm) const
{
return Slicer::StreamSerializerFactory::createNew(
"application/json", strm);
}
}
|