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

Commit

Permalink
Fix route registration order in rest_resource example
Browse files Browse the repository at this point in the history
  • Loading branch information
r3mus-n0x committed Nov 7, 2018
1 parent 430d712 commit 388a91e
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 388a91e

Please sign in to comment.