Skip to content

Instantly share code, notes, and snippets.

@FROGGS

FROGGS/Foobar.pm Secret

Created July 25, 2017 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FROGGS/d14fb9f9b6cd6f33acb26cc11cf7ffe2 to your computer and use it in GitHub Desktop.
Save FROGGS/d14fb9f9b6cd6f33acb26cc11cf7ffe2 to your computer and use it in GitHub Desktop.
$(document).ready(function () {
$.ajax({ type: "HEAD", url: '/foobar', dataType: "html", }).done(function (data) { console.log(data) }); // NOK, gives 404
$.ajax({ type: "LINK", url: '/foobar', dataType: "html", }).done(function (data) { console.log(data) }); // OK
$.ajax({ type: "UNLINK", url: '/foobar', dataType: "html", }).done(function (data) { console.log(data) }); // OK
$.ajax({ type: "FLUBBER", url: '/foobar', dataType: "html", }).done(function (data) { console.log(data) }); // OK
$.ajax({ type: "FOOBAR", url: '/foobar', dataType: "html", }).done(function (data) { console.log(data) }); // OK
});
package Foobar;
use Mojo::Base 'Mojolicious';
use feature ':5.24';
use experimental qw(signatures refaliasing);
no warnings qw(experimental);
sub startup($app) {
my $r = $app->routes;
# neither of these work
$r->any(['HEAD'] => '/foobar')->to(cb => sub { warn; shift->render(json => '"HEAD"' ) });
$r->_generate_route(HEAD => '/foobar')->to(cb => sub { warn; shift->render(json => '"HEAD"' ) });
# but these do work
$r->any(['LINK'] => '/foobar')->to(cb => sub { warn; shift->render(json => '"LINK"' ) });
$r->any(['UNLINK'] => '/foobar')->to(cb => sub { warn; shift->render(json => '"UNLINK"' ) });
$r->any(['FLUBBER'] => '/foobar')->to(cb => sub { warn; shift->render(json => '"FLUBBER"' ) });
$r->_generate_route(FOOBAR => '/foobar')->to(cb => sub { warn; shift->render(json => '"FOOBAR"' ) });
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment