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

Auto_page setting with fallback routes #1081

Open
murwiz opened this issue Oct 10, 2014 · 0 comments
Open

Auto_page setting with fallback routes #1081

murwiz opened this issue Oct 10, 2014 · 0 comments

Comments

@murwiz
Copy link

murwiz commented Oct 10, 2014

This may well be a naive question, but here goes:

In Dancer::Plugin::Interchange6::Routes there is a fallback route intended to fire on various vanilla requests. At the end of the route, assuming it's found nothing else, it does this:

status 'not_found';
forward '404';

I was trying to make an Interchange6 application work with the auto_page directive, so I really want the fallback to not generate a 404 at this point, but instead hand off to the auto_page code. So I prepended this:

return if setting 'auto_page';

However, this just generates an empty page. Upon further digging, I figured out why:

Dancer::Renderer:
sub render_action {
my $class = shift;
my $resp = $class->get_action_response();
return (defined $resp)
? response_with_headers()
: undef;
}

In my scenario, what is being returned here is not Perly false, but --

bless( {'content' => '','encoded' => 0,'forward' => '','halted' => 0,'headers' => bless( {'content-type' => 'text/html'}, 'HTTP::Headers' ),'pass' => 0,'status' => 200}, 'Dancer::Response' )

So I have naively changed the render_action code locally to:

...
return (defined $resp and (length $resp->{content} or $resp->{status} != 200))

which seems to work. Is there a reason why render_action "succeeds" in this case (where the returned content is empty)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant