Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to register parameterized routes? #399

Open
amigo421 opened this issue Mar 29, 2017 · 2 comments
Open

how to register parameterized routes? #399

amigo421 opened this issue Mar 29, 2017 · 2 comments

Comments

@amigo421
Copy link

amigo421 commented Mar 29, 2017

does the SDK support a routes with a parameter similar to node js does , using : id in a path:
app.post('/api/session', sessions.post);
app.get('/api/session/:id', sessions.get);
app.put('/api/session/:id', sessions.put);
app.delete('/api/session/:id', sessions.delete);

@cmazakas
Copy link

cmazakas commented Mar 29, 2017

Unfortunately, there is no router in place. I've been looking into this myself.

I think what I'm going to ultimately do is make my own router and then see if MS wants in on it. Keep in mind, they're not going 100% for their http_listener as the library is focused on service-consumption first and foremost.

However, the library is basically useless without the http_listener so we kind of have to patch it ourselves.

I figured, the easiest way to make a router would be to use Boost's property_tree data structure and parse the relative URIs for each http_request that comes in.

Also, Express.js has convinced me, regexes in routers need to die! Instead, I'm opting to design routes with default handlers instead of this regex nonsense :P

@JoshuaBehrens
Copy link
Contributor

I have a router patched into the http_listener for a project I am working on. As I have some code supporting this I'd like to have some details for specific keypoints I could directly build into.

Currently it is just a basic std::map<utility::string_t, utility::string_t> that contains all values of the parameterized URI. To register it right you give URIs like in the example from @amigo421 . But I tend to rewrite it as a decorator to the existing code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants