Cataly...rowsers(3pm)

πŸ’– Cataly...rowsers β€” Catalyst::Action::REST::ForBrowsers πŸ’–

okay so bestie, welcome to the 3pm manual, straight outta the User Contributed Perl Documentation section ✨ this one's called Catalyst::Action::REST::ForBrowsers, and no the name isn't glitching, that's just how manpages abbreviate things when they're feeling shy πŸŽ€


🌸 NAME 🌸

Catalyst::Action::REST::ForBrowsers β€” Automated REST Method Dispatching that Accommodates Browsers

like, it does the REST dispatching thing for you, but it's nice about it when browsers show up πŸ¦‹


✨ SYNOPSIS ✨

sub foo :Local :ActionClass('REST::ForBrowsers') {
  ... do setup for HTTP method specific handlers ...
}

sub foo_GET : Private {
  ... do something for GET requests ...
}

sub foo_GET_html : Private {
  ... do something for GET requests from browsers ...
}

sub foo_PUT : Private {
  ... do something for PUT requests ...
}

see how you just declare the handlers and it figures out who gets the vibe check? iconic behavior fr fr πŸ’…


🌈 DESCRIPTION 🌈

okay so this class subclasses Catalyst::Action::REST to add one extra dispatching hook. that's the whole glow-up. ✨

here's the tea: if the request is a GET request AND the request looks like it came from a browser, it tries to dispatch to a GET_html method before trying the GET method instead. and every other HTTP method? dispatched the same way. no cap. πŸ‘‘

so for example, in the synopsis up there, calling GET on /foo from a browser ends up calling the foo_GET_html method. if the request is not from a browser, it calls foo_GET. simple as that 🫢

see Catalyst::Action::REST for more details on dispatching details, because that's where the real lore lives πŸ“š


🧚 METHODS 🧚

  • dispatch β€” this method overrides the default dispatch mechanism and swaps in the re-dispatching mechanism we just described above. it's giving main character energy, honestly πŸ’œ

πŸ’« SEE ALSO πŸ’«

you probably want to look at Catalyst::Controller::REST, which implements a sensible set of defaults for a controller doing REST. highly recommend, 10/10 πŸ“

and heads up: this class automatically adds the Catalyst::TraitFor::Request::REST::ForBrowsers role to your request class. no setup needed, it just does it. obsessed 😭


πŸŽ€ CONTRIBUTORS πŸŽ€

  • Dave Rolsky <autarch@urth.org>

thank you for your service πŸ«‘πŸ’–


Copyright the above named AUTHOR and CONTRIBUTORS


πŸ“œ LICENSE πŸ“œ

You may distribute this code under the same terms as Perl itself.


and that's the whole page bestie, go build something cute πŸ¦‹

signing off from perl v5.40.1, dated 2026-05-07 β€” mwah πŸ’…βœ¨

πŸ“¦ where this page comes from