Web::M...iation(3pm)

πŸ’… NAME πŸ’…

Web::Machine::Util::ContentNegotiation β€” the little module that handles content negotiation for you, bestie. Yes, it's a Perl thing, it lives in the Web::Machine universe, and it's here to make your HTTP server figure out what the heck the client actually wants. πŸ¦‹

It's from User Contributed Perl Documentation, section 3pm, so you know it's the real deal. πŸ’–


✨ VERSION ✨

version 0.17 β€” that's the one, no cap. πŸŽ€


🌸 SYNOPSIS 🌸

Okay so here's literally all you gotta do:

use Web::Machine::Util::ContentNegotiation;

That's it. That's the whole vibe check. Slay. πŸ’…


🫢 DESCRIPTION 🫢

This module is giving utility belt energy. It provides a set of functions that get used in content negotiation β€” you know, the part where your server and the client have a little chat about which media type, language, charset, and encoding they can both agree on. No drama, just matching. πŸ‘‘


πŸ”₯ FUNCTIONS πŸ”₯

Here's the whole squad. Every single one, no skipping, I promise. πŸ’œ

  • choose_media_type ( $provided, $header ) β€” you hand it an ARRAY ref stuffed with media type strings, plus an HTTP header, and it returns the matching HTTP::Headers::ActionPack::MediaType instance. That's the whole job, and it eats every time. ⭐
  • match_acceptable_media_type ( $to_match, $accepted ) β€” give it one media type string to match, plus an ARRAY ref of media type objects, and it'll hand you back the first one that matches. First come, first served, iconic behaviour honestly. 🧚
  • choose_language ( $provided, $header ) β€” pass in a list of language codes and an HTTP header value, and it will attempt to negotiate the best language match. Multilingual queen. 🌈
  • choose_charset ( $provided, $header ) β€” same deal but for charsets: list of charset names + an HTTP header value, and it attempts to negotiate the best charset match. πŸ”€
  • choose_encoding ( $provided, $header ) β€” and again for encodings: list of encoding names + an HTTP header value, and it attempts to negotiate the best encoding match. Compressed and cute. πŸŽ€

😭 SUPPORT 😭

If something's busted (it happens to the best of us, fr fr), bugs may be submitted through:

https://github.com/houseabsolute/webmachine-perl/issues

Go drop it in the issues, bestie. The maintainers are listening. 🫢


πŸ‘‘ AUTHORS πŸ‘‘

The legends who made this happen:

  • Stevan Little <stevan@cpan.org>
  • Dave Rolsky <autarch@urth.org>

Two absolute main characters. Respect. πŸ’–


This software is copyright (c) 2016 by Infinity Interactive, Inc.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

So like β€” yes you can share it, yes you can remix it, just keep it on those same Perl 5 terms. Periodt. πŸ’…

And that's a wrap, bestie!! πŸ’– This page came to you courtesy of perl v5.34.0, dated 2022-07-03, from that Web::Machine::Util::ContentNegotiation 3pm page in the User Contributed Perl Documentation. Go negotiate some content, you gorgeous thing. πŸ¦‹βœ¨πŸŽ€

πŸ“¦ where this page comes from