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

Commit

Permalink
Merge pull request #44 from r3mus-n0x/master
Browse files Browse the repository at this point in the history
Fix route registration order in rest_resource example
  • Loading branch information
Jeffail authored Nov 7, 2018
2 parents 193b141 + 388a91e commit d492572
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/examples/rest_resource/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,8 @@ int main(int, char const**)
{
served::multiplexer mux;

mux.handle("/customers")
.get([](served::response & res, const served::request & req) {
(void) res;
(void) req;
// list customers
})
.post([](served::response & res, const served::request & req) {
(void) res;
(void) req;
// create customer
});

// register a more specialized route first, otherwise all requests with
// "/customers" prefix will be routed to "/customers" handlers
mux.handle("/customers/{id}")
.get([](served::response & res, const served::request & req) {
(void) res;
Expand All @@ -63,6 +53,18 @@ int main(int, char const**)
// delete customer req.params["id"]
});

mux.handle("/customers")
.get([](served::response & res, const served::request & req) {
(void) res;
(void) req;
// list customers
})
.post([](served::response & res, const served::request & req) {
(void) res;
(void) req;
// create customer
});

served::net::server server("127.0.0.1", "8123", mux);
server.run(10);

Expand Down

0 comments on commit d492572

Please sign in to comment.