You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's always recommended to use params instead of getting params or body directly from the request resource. If you do that intentionally, always make sure to run validation right after fetching such a raw input.
148
148
149
+
### Multiple Methods
150
+
151
+
A route can be registered under additional paths and multiple HTTP methods. All matching paths and methods dispatch to the same route, so the action, params, and hooks are defined only once.
152
+
153
+
Use `alias()` to serve the same route under another path, for example to keep a legacy URL working:
// $request->getMethod() tells how the request arrived (GET or POST)
173
+
$response->json(['sub' => 'user-id']);
174
+
});
175
+
```
176
+
177
+
Path aliases and multiple methods combine: a route with both responds on every method under every path. Use `getMethods()` to inspect the methods a route was registered with, and use the request resource to tell how a request arrived.
0 commit comments