Dynamic routing parameters
marcusoftnet opened this issue · comments
Marcus Hammarberg commented
Hi guys - love the project. Dead simple to get started with.
I'd love a simple routing enhancement so that you can catch parameters in the URL.
var ApiBuilder = require("claudia-api-builder");
var api = new ApiBuilder();
api.get("/get/{id}", function (request) {
return request.id;
});
So if I access this with /get/123
I'll get 123
back
Gojko Adzic commented
try request.pathParams.id
- should work already
Gojko Adzic commented
(just make sure you're using the latest API builder, so it can handle sub-routes). I've updated the Request Object docs to show the path params, and added another example to the web api project to show how to use them.
Marcus Hammarberg commented
Bah! Saw that now. Sorry!
Gojko Adzic commented
no need to be sorry, it wasn't in the docs. it was in the code, though, so this was a nice documentation bug report :)