Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- Adds two methods: .not-supported and .server-error which will return status codes 500 and 505, respectively. #195

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading