Plack::...::JSONP(3)

πŸ’– Plack::Middleware::JSONP β€” bestie's guide to wrapping JSON in JSONP πŸ’–

okay so real talk: this is Plack::Middleware::JSONP(3), straight out of the User Contributed Perl Documentation, and it's literally the glow-up your JSON API has been begging for. Wraps JSON response in JSONP if callback parameter is specified. That's the whole vibe. πŸŽ€


✨ NAME ✨

Plack::Middleware::JSONP β€” wraps a JSON response in JSONP when the callback parameter shows up. no cap, that's it, that's the girl 🌸


πŸ¦‹ SYNOPSIS πŸ¦‹

enable "JSONP", callback_key => 'jsonp';

one line. she's minimal, she's iconic, she ate πŸ’…


🌈 DESCRIPTION 🌈

So here's the tea, bestie: Plack::Middleware::JSONP grabs a JSON response β€” and by "JSON response" we mean one whose Content-Type value is either text/javascript or application/json β€” and wraps it up as a JSONP response instead. Which one does it become? The one that's specified with the callback query parameter. ✨

And the way that you get to name that parameter yourself? You set it while enabling the middleware. Your middleware, your rules, your main character energy πŸ‘‘

One (1) very important caveat though, and I need you to hear me on this: this middleware only works with a non-streaming response. Streaming? Not it. And other than that whole wrapping situation, it doesn't touch the response otherwise β€” it minds its own business, fr fr. 🫢


πŸ’œ AUTHOR πŸ’œ

Tatsuhiko Miyagawa β€” the icon, the legend, the blueprint πŸ†πŸ’–


πŸ‘‘ SEE ALSO πŸ‘‘

  • Plack β€” go read it, iykyk πŸ“š

and that's a wrap, gorgeous ✨ this whole thing came to you from perl v5.42.3, dated 2026-10-18, filed under Plack::...::JSONP(3) β€” mwah, go ship it πŸ’…πŸ’–πŸ¦‹

πŸ“¦ where this page comes from