404 Not Found in Dancer
If a user tries to access a path that has no matching route defined then Dancer will return a default "404 Not Found" error page
with the appropriate HTTP status code.
Later we'll see how can we change the content of this page to be branded to our site.
examples/dancer/hello_404/app.psgi
package App; use Dancer2; get '/' => sub { return 'Hello World!'; }; App->to_app;
examples/dancer/hello_404/test.t
use strict; use warnings; use Test::More; use Plack::Test; use Plack::Util; use HTTP::Request::Common; my $app = Plack::Util::load_psgi './app.psgi'; my $test = Plack::Test->create($app); subtest main => sub { my $res = $test->request(GET '/'); is $res->status_line, '200 OK', 'Status'; is $res->content, 'Hello World!', 'Content'; }; subtest not_found => sub { my $res = $test->request(GET '/first'); is $res->status_line, '404 Not Found', 'Status'; like $res->content, qr{<title>Error 404 - Not Found</title>}; like $res->content, qr{Powered by <a href="http://perldancer.org/">Dancer2</a>}; }; done_testing();