Protecting New Doors (API Endpoints)

Learn how to create a middleware in Laravel and use it to protect routes.

Middleware introduction

Middleware can help with authentication, authorization, and other request-related task. Since middleware is executed before the request, developers find innovative ways to use them to enforce business rules.

Terminable middlewares can help us with the responses as well.

Creating a middleware

In this course, we will use middleware to check that the ‘restaurant ID’ is passed for all the upcoming API endpoints and that the logged-in user owns that restaurant.

Get hands-on with 1200+ tech skills courses.