Chapter 3 of the Discover Goravel track

Locking up the depot

Group an API's routes under a prefix, then protect it with a middleware.

2 exercises · 200 XP · about 40 min

This chapter works on: Route groupPrefixAnonymous functionMiddlewareHTTP headerInterface

The chapter's exercises

  1. The couriers' API

    Exercise 1 · 100 XP · 3 objectives checked by tests

    The couriers' app and the depot board have their URLs all mixed together. Margot would like to put everything the app uses under /api, as in the Laravel projects she has seen.

    Route groupPrefixAnonymous function

  2. The depot key

    Exercise 2 · 100 XP · 3 objectives checked by tests

    The neighbor's son found the API's URL, and he's having fun ordering deliveries for his cat. Margot gave the couriers' app a key, which it sends in the X-Cle-Coursier header (“courier key”) of every request. The API has to check it.

    MiddlewareHTTP headerInterface