Course of Raku / Functional, concurrent, reactive, and web programming / Web programming / Cro 101 / Exercises / A second route
Solution: A second route
Here is a possible solution to the task.
Code
use Cro::HTTP::Router;
my $application = route {
get -> 'hello' {
content 'text/plain', 'Hello from Cro!';
}
get -> 'bye' {
content 'text/plain', 'Goodbye!';
}
}🦋 You can find the source code in the file second-route.raku.
Output
Goodbye!Comments
A
routeblock can hold as many routes as you like; eachgethandles one path.Cro matches the request path to the right route, so
/helloand/byereturn their own responses.
Course navigation
← A second route | Addendum 🆕 →