diff --git a/lib/Dancer2/Manual.pod b/lib/Dancer2/Manual.pod index 951a268d3..ed06348db 100644 --- a/lib/Dancer2/Manual.pod +++ b/lib/Dancer2/Manual.pod @@ -247,14 +247,14 @@ under C and all rides under C. These DSL keywords in Dancer2 allow you to manage the flow of actions within your routes. Here’s how they work in Danceyland. -=head2 forward +=head3 forward C allows you to forward the current request to another route handler, as if it were redirected, but without sending a new HTTP request. Put another way, a different route than the one requested is processed, but the address in the user's browser's bar stays the same. -=head3 Example +=head4 Example get '/guest-services' => sub { forward '/info'; # Forwards to /info @@ -268,14 +268,14 @@ In this example, when a visitor goes to C, they are forwarded to the C route internally, however, the vistor's browser still shows they are in C. -=head2 redirect +=head3 redirect C sends an HTTP redirect to the client, instructing their browser to make a new request to a different URL. At the end of the request, the user's browser will show a different URL than the one they originally navigated to. -=head3 Example +=head4 Example get '/old-roller-coaster' => sub { redirect '/new-roller-coaster'; @@ -288,12 +288,12 @@ they originally navigated to. When a visitor requests C, they are redirected to C. The browser's URL will now show C. -=head2 pass +=head3 pass C tells Dancer2 to skip the current route and continue looking for the next matching route. -=head3 Example +=head4 Example get '/vip-area' => sub { if (!session('is_vip')) { @@ -315,6 +315,29 @@ TODO: need an explanation here =head3 Keywords for working with parameters +=head4 param and params (Not Recommended) + +The C and C keywords are legacy methods to access request parameters. While still functional, they are not recommended for new applications. Instead, you should use the more specific keywords like C, C, and C for clarity and precision. + +=head4 Example: Using param (Not Recommended) + + get '/submit' => sub { + # Please use query_parameters() shown below + my $name = param('name'); + return "Submitted name: $name"; + }; + +=head4 Example: Using params (Not Recommended) + + get '/all-params' => sub { + # Pleaase use query_parameters() shown below + my %all_params = params; + return "All parameters: " . join(', ', %all_params); + }; + +C and C are included here for completeness but are not the +preferred methods for handling parameters in Danceyland. + =head4 body_parameters This keyword retrieves parameters from the body of the request, typically @@ -341,6 +364,8 @@ Example of C with multiple values: return "Search query: $query in category: $category"; }; +The above route would match the URL C. + =head4 route_parameters This keyword retrieves parameters from the route pattern.