Route model binding using middleware
Freek Van der Herten has another good tutorial about route model binding using middleware.
Our team is currently working on a Spark app. Spark makes is real easy to add an API that can be consumed by the users of the app. The generation of API tokens and authentication middleware comes out of the box. It all works really great.
In our API the a team owner can fetch information on every member on the team and himself. The url to fetch info of a user looks something like this: /users/
. Nothing too special. But we also want to make fetching a user’s own information as easy as possible. Sure, the user could look op his own userid and then call the aforementioned url, but using something like /users/me is much nicer. In this way the user doesn’t have to look op his own id. Let’s make that possible.
This post is submitted by one of our members. You may submit a new post here.