|
Boost : |
Subject: Re: [boost] [http] Design ideas for a request router
From: Sorin Fetche (sorin.fetche_at_[hidden])
Date: 2016-03-17 13:00:03
Hi all,
On Sun, Mar 13, 2016 at 11:58 PM, VinÃcius dos Santos Oliveira <> wrote:
> The "tree style" is the style where you declare some paths to be handled
> and each request will be routed to at most one handler. You'll find this
> style usually when the author advertise a ReST support library
> (e.g.crow[1]).
This is also the style we used in an in house server side library
meant to be used mainly for REST and WebSocket connections.
The routing is inspired from Python Flask and Python aiohttp [1] with
these features:
- the routes can be added and removed at runtime (and from other route handlers)
- we needed dynamic routes - moreover the dynamic part needed to match
multiple path segments and more "specific" route handlers needed to
take precedence over the more "generic" ones (example below)
- support for asynchronous (deferred) route handlers - to support the
cases when handling a request requires a lengthy operation.
- full access to request / response objects to offload as much logic
as possible from the core server library.
Example of specific / generic route handlers:
("POST", "/api/v1/<device_id>/operation_a/") - handles some POST requests
("POST", "<url>/") - handles all the other POST requests regardless
how many path segments (matches both "/a/" and "a/b/" and so on)
[1] Python aiohttp: http://aiohttp.readthedocs.org/en/stable/web.html
Best regards,
Sorin Fetche
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk