claudiajs / claudia-api-builder

Use AWS API Gateway as if it were a lightweight JavaScript web server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dynamic routing parameters

marcusoftnet opened this issue · comments

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

try request.pathParams.id - should work already

(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.

Bah! Saw that now. Sorry!

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 :)