Skip to main content

6 docs tagged with "Routing"

View all tags

Caching

Routes which return static, public assets (such as language strings and templates) can be made cacheable by browsers and reverse proxies by setting the cachelifetime property of the \core\router\route attribute.

Defining Scopes

Scopes describe what an OAuth2 access token or Personal Access Token is allowed to do, and are declared on a route using the #[scopeset] attribute. This page describes how to define the scope classes that make up that catalogue in the first place.

Scopes

API routes are protected by Moodle's normal login and capability checks, but when a request is authenticated with an OAuth2 access token, or a Personal Access Token, the router also enforces Scopes. A scope is a small, named permission (for example core_userread) that describes what a particular token is allowed to do.

The Fetch batcher

The core/fetch module makes requests to the Moodle REST API (routes). In addition to immediate requests, it can queue several requests and send them as a single HTTP $batch request, reducing the number of round trips.

Unit Testing

One of the benefits of using routes is how easy they are to unit test. It is also possible to test parameters for validation, which is especially useful for mapped parameters.