Skip to content

Commit

Permalink
- Adds two methods: .not-supported and .server-error which will retur…
Browse files Browse the repository at this point in the history
…n status codes 500 and 505, respectively.
  • Loading branch information
Xliff committed Jul 9, 2024
1 parent d21b6c6 commit 604f944
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lib/Cro/HTTP/Router.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,36 @@ module Cro::HTTP::Router {
content $content-type, $body, |%options;
}

proto server-error(|) is export {*}

#| Produce a HTTP 500 Server Error response
multi server-error(--> Nil) {
set-status(500, :action<server-errror>);
}

#| Produce a HTTP 500 Server Error response. The remaining arguments will be
#| passed to the content function, setting the media type, response body, and
#| other options.
multi server-error($content-type, $body, *%options --> Nil) {
set-status(500, :action<server-error>);
content $content-type, $body, |%options;
}

proto not-supported(|) is export {*}

#| Produce a HTTP 505 Not Supported response
multi not-supported(--> Nil) {
set-status(505, :action<not-supported>);
}

#| Produce a HTTP 505 Not Supported response. The remaining arguments will be
#| passed to the content function, setting the media type, response body, and
#| other options.
multi not-supported($content-type, $body, *%options --> Nil) {
set-status(505, :action<not-supported>);
content $content-type, $body, |%options;
}

#| Add a cookie to the response
sub set-cookie($name, $value, *%opts) is export {
my $resp = $*CRO-ROUTER-RESPONSE //
Expand Down

0 comments on commit 604f944

Please sign in to comment.