Open seppy87 opened 3 years ago
My REST server is using get for getting Informations and POST to update. But if I am using GET and POST for /settings then it will throw a served::request_error when I try to GET Request for Settings the REST Client says Method not allowed.
void KSecureDesktopServer::initREST() { //General Settings served::multiplexer& mux = this->multiplexer; auto* sender = this; mux.handle("/settings").get([this](served::response& res, const served::request& req) { this->getSettings(res, req); //throws an exception }); mux.handle("/settings").post([this](served::response& res, const served::request& req) { this->postSettings(res, req); }); // works //Get User Info mux.handle("/user").get([this](served::response& res, const served::request& req) { // this->getUser(res, req); int i = 0; res << "SUCCESS"; //works } ); // mux.handle("/user").post([this](served::response& res, const served::request& req) {this->postUser(res, req); }); // mux.handle("/user").put([this](served::response& res, const served::request& req) {this->putUser(res, req); }); //mux.handle("/user").del([this](served::response& res, const served::request& req) {this->deleteUser(res, req); }); //Channels //mux.handle("/channel").get([this](served::response& res, const served::request& req) {this->getChannel(res, req); }); //mux.handle("/channel").post([this](served::response& res, const served::request& req) {this->postChannel(res, req); }); //mux.handle("/channel").put([this](served::response& res, const served::request& req) {this->putChannel(res, req); }); //mux.handle("/channel").del([this](served::response& res, const served::request& req) {this->deleteChannel(res, req); }); this->restServer = std::make_unique<served::net::server>("127.0.0.1", "8080", mux); this->restServer->run(10,false); }
Multiplexer is a Class member and net::server is a smart pointer.
can handle both requests
Windows 10 x64 Visual Studio 2019 Community Edition
Describe the bug
My REST server is using get for getting Informations and POST to update. But if I am using GET and POST for /settings then it will throw a served::request_error when I try to GET Request for Settings the REST Client says Method not allowed.
Steps to reproduce
Multiplexer is a Class member and net::server is a smart pointer.
Expected behavior
can handle both requests
Environment (anything that would help us investigate the bug)
Windows 10 x64 Visual Studio 2019 Community Edition