-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathRestDbRequestHandlerFactory.cpp
44 lines (34 loc) · 1.32 KB
/
RestDbRequestHandlerFactory.cpp
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
//
// Created by victor on 24/10/17.
//
#include "RestDbRequestHandlerFactory.h"
#include "RestDbRequestHandler.h"
#include "LoggingFilter.h"
#include "Validations.h"
#include "CorsFilter.h"
#include <proxygen/httpserver/filters/DirectResponseHandler.h>
#include <boost/spirit/include/classic.hpp>
#include <proxygen/httpserver/Filters.h>
namespace restdbxx {
void RestDbRequestHandlerFactory::onServerStart(folly::EventBase *evb)noexcept {
}
void RestDbRequestHandlerFactory::onServerStop() noexcept {
}
proxygen::RequestHandler *RestDbRequestHandlerFactory::onRequest(proxygen::RequestHandler *handler,
proxygen::HTTPMessage *message) noexcept {
proxygen::RequestHandler *resultHandler = nullptr;
std::string path = message->getPath();
Validations::sanitize_path(path);
if (Validations::is_valid_path(path)) {
VLOG(google::GLOG_INFO) << "el path es valido ";
resultHandler = new RestDbRequestHandler();
} else if (handler != nullptr) {
VLOG(google::GLOG_WARNING) << "el path no es valido, pasando el control al siguiente handler";
resultHandler = handler;
} else {
VLOG(google::GLOG_WARNING) << "el path no es valido ";
resultHandler = new proxygen::DirectResponseHandler(500, "Wierd error", "not really");
}
return resultHandler;
}
}