mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralfms.git
synced 2026-01-27 10:23:12 +00:00
RESTAPI refactor
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user