@@ -568,6 +568,20 @@ Action format is C<scope.method> where scope is one of C<http>, C<sse>, or
568568C<websocket > , and method is an HTTP method for C<http > or C<sse > scope, or
569569omitted for C<websocket > . Either part can be C<* > to match anything.
570570
571+ If a C<.get > route is created, it is automatically valid for similar C<HEAD >
572+ requests as well. If special C<HEAD > handling is required, a check can be made
573+ in handler code:
574+
575+ sub handle ($self, $ctx)
576+ {
577+ ...; # set headers
578+
579+ # return empty (but defined) response if we have HEAD, full body
580+ # otherwise
581+ return '' if $ctx->req->is_head;
582+ return 'full body';
583+ }
584+
571585Common action patterns:
572586
573587 # Match only HTTP POST requests
@@ -579,7 +593,7 @@ Common action patterns:
579593 # Match only WebSocket connections
580594 action => 'websocket'
581595
582- # Match only Server-Sent GET Events
596+ # Match only Server-Sent GET and HEAD Events
583597 action => 'sse.get'
584598
585599 # Match any request type (default)
@@ -592,6 +606,16 @@ allowing different handlers for different request types:
592606 $router->add('/api/data' => { to => 'post_data', action => 'http.post' });
593607 $router->add('/api/data' => { to => 'stream_data', action => 'websocket' });
594608
609+ If the handler is the same for all actions, it can be achieved with a simple
610+ for loop:
611+
612+ for my $action (qw(http.get http.post websocket)) {
613+ $router->add('/api/data' => { to => 'handle_api_data', action => $action });
614+ }
615+
616+ Make sure that the order of route building is deterministic, and that C<name >
617+ (if provided) is unique.
618+
595619=head3 PAGI compatibility
596620
597621Thunderhorse was coded in such a way that allows it to fully integrate the PAGI
0 commit comments