开发者

Match any GET path with Mojolicious::Lite

开发者 https://www.devze.com 2023-01-04 01:00 出处:网络
开发者_JAVA技巧I’d like to match any GET request in Mojolicious::Lite. The code looks like this:

开发者_JAVA技巧I’d like to match any GET request in Mojolicious::Lite. The code looks like this:

get '.*' => sub {
    my $self = shift;
    $self->render(text => 'Nothing to see here, move along.');
};

This dies with “Modification of non-creatable array value attempted” at MojoX::Routes::Pattern.pm, line 301. I tried other arguments to get, like qr//. That works for /, but does not match /foo. I also tried to peek at the source, but I’m none the wiser. Are you?


I think you want:

get '/(*restofpath)' => ...

(The restofpath is a name that will allow you to retrieve the actual pathname later, should you need it...). For more details, look at the documentation for wilcard placeholders.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号