← Back to context

Comment by ashtonjamesd

4 days ago

Hi, sorry maybe I should've added a comment for that.

The 'appRoute' is a macro that expands to a function signature.

The macro is: '#define appRoute(name) HttpResponse name(AppContext ctx)' and the parameter I passed as 'home' is expanded into the function name. The reason is because all controller function signatures are the same, so just writing 'appRoute' allows the developer to save time writing endpoints!

It is a tradeoff between readability and development speed. And one of the ideas behind the framework is succint and minimal code.

Thanks for explaining. I was also a bit confused at a first where the home variable being passed into get() was coming from.

So it creates a function called "home", and that is what you pass to get?

Makes sense, thanks!