Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.

Handle same path for POST and get throws Error #74

Description

@seppy87

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

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.

Expected behavior

can handle both requests

Environment (anything that would help us investigate the bug)

Windows 10 x64
Visual Studio 2019 Community Edition

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions