RESTAPI refactor

This commit is contained in:
stephb9959
2021-09-12 10:48:37 -07:00
committed by oblom0v
parent 3c97df5ebd
commit 5bf49fa6fa
3 changed files with 7 additions and 6 deletions

2
build
View File

@@ -1 +1 @@
11
13

View File

@@ -38,7 +38,7 @@ namespace OpenWifi {
if (!ContinueProcessing())
return;
if (!IsAuthorized())
if (AlwaysAuthorize_ && !IsAuthorized())
return;
ParseParameters();
@@ -55,8 +55,7 @@ namespace OpenWifi {
}
const Poco::JSON::Object::Ptr &RESTAPIHandler::ParseStream() {
Poco::JSON::Parser IncomingParser;
return IncomingParser.parse(Request->stream()).extract<Poco::JSON::Object::Ptr>();
return IncomingParser_.parse(Request->stream()).extract<Poco::JSON::Object::Ptr>();
}
bool RESTAPIHandler::ParseBindings(const std::string & Request, const std::list<const char *> & EndPoints, BindingMap &bindings) {

View File

@@ -92,8 +92,8 @@ namespace OpenWifi {
typedef std::map<std::string, std::string> BindingMap;
RESTAPIHandler(BindingMap map, Poco::Logger &l, std::vector<std::string> Methods, bool Internal=false)
: Bindings_(std::move(map)), Logger_(l), Methods_(std::move(Methods)), Internal_(Internal) {}
RESTAPIHandler(BindingMap map, Poco::Logger &l, std::vector<std::string> Methods, bool Internal=false, bool AlwaysAuthorize=true)
: Bindings_(std::move(map)), Logger_(l), Methods_(std::move(Methods)), Internal_(Internal), AlwaysAuthorize_(AlwaysAuthorize) {}
static bool ParseBindings(const std::string & Request, const std::list<const char *> & EndPoints, BindingMap &Keys);
void PrintBindings();
@@ -171,6 +171,8 @@ namespace OpenWifi {
bool QueryBlockInitialized_=false;
Poco::Net::HTTPServerRequest *Request= nullptr;
Poco::Net::HTTPServerResponse *Response= nullptr;
bool AlwaysAuthorize_=true;
Poco::JSON::Parser IncomingParser_;
};
class RESTAPI_UnknownRequestHandler : public RESTAPIHandler {