-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathFiltersFactory.cpp
More file actions
28 lines (24 loc) · 889 Bytes
/
FiltersFactory.cpp
File metadata and controls
28 lines (24 loc) · 889 Bytes
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
//
// Created by victor on 11/13/17.
//
#include <proxygen/httpserver/filters/DirectResponseHandler.h>
#include "FiltersFactory.h"
#include "LoggingFilter.h"
#include "CorsFilter.h"
#include "AuthenticationFilter.h"
namespace restdbxx {
std::vector<std::string> FiltersFactory::_blacklist = {
"/favicon.ico"
};
void FiltersFactory::onServerStart(folly::EventBase *evb) noexcept {
}
void FiltersFactory::onServerStop()noexcept {
}
proxygen::RequestHandler *FiltersFactory::onRequest(proxygen::RequestHandler *handler,
proxygen::HTTPMessage *message)noexcept {
if (std::find(_blacklist.begin(), _blacklist.end(), message->getPath()) != _blacklist.end())
return new proxygen::DirectResponseHandler(404, "Not Found", "Not Found");
auto f = new LoggingFilter(new CorsFilter(new AuthenticationFilter(handler)));
return f;
}
}