HTTP::Link(3pm)

πŸ“¦
version 0.001 Β· 2 versions
  • 0.001 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.001 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ NAME ✨

HTTP::Link β€” bestie, it's literally RFC5988 Web Linking, the whole thing, in Perl πŸ’…


🌸 VERSION 🌸

version 0.001 β€” baby version, iconic debut era πŸŽ€


πŸ’– METHODS πŸ’–

πŸ¦‹ new

Returns a brand-new Web Link, as a string, slay ✨

my $link = HTTP::Link->new('/TheBook/Chapter/2',
    relation => 'next',
    title => 'next chapter',
);
# Result:
# </TheBook/Chapter/2>; rel="next"; title="next chapter"

Args, bestie:

  • $iri β€” an internationalized resource identifier. It's the target uri reference, periodt.
  • %options β€” extra parameters, keep reading πŸ‘‡

Params for %options:

  • "relation" β€” the possible relation types are: alternate, appendix, bookmark, chapter, contents, copyright, current, describedby, edit, edit-media, enclosure, first, glossary, help, hub, index, last, latest-version, license, next, next-archive, payment, prev, predecessor-version, previous, prev-archive, related, replies, section, self, service, start, stylesheet, subsection, successor-version, up, version-history, via, working-copy, working-copy-of and others (see IANA registry). Yeah, it's a whole list, we love an exhaustive moment πŸ’€
  • "extension" β€” an extension for a relation type.
  • "anchor" β€” an anchor for the context IRI.
  • "hreflang" β€” a hint telling you what the language of the destination's content is 🌈
  • "media" β€” the intended destination medium, like in a CSS media query.
  • "title" β€” a human-readable label. This one gets encoded with MIME::EcoEncode.
  • "type" β€” a hint indicating the most possible MIME type of the destination's content.

πŸŽ€ rel

A shortcut method for new, but with a different signature β€” it's giving remix ✨

HTTP::Link->rel('/TheBook/Chapter/2',
    start => '/TheBook/Chapter/0'
);
# same as
HTTP::Link->new('/TheBook/Chapter/2',
    relation => 'start',
    extension => '/TheBook/Chapter/0',
);

Args:

  • $iri β€” see new above, bestie.
  • $relation β€” will be appended to %options by relation = $relation >> πŸ’…
  • $extension β€” will be appended to %options by extension = $extension >>
  • %options β€” see new.

πŸ’œ multi

When you need more than one link, this is the method, no cap. It accepts a hash or a HashRef with a mapping of IRIs to options 🫢

HTTP::Link->multi(
    '/TheBook/Chapter/2' => {
        relation => 'previous'
    },
    '/TheBook/Chapter/4' => {
        relation => 'next'
    },
);
# Result:
# </TheBook/Chapter/2>; rel="previous", </TheBook/Chapter/4>; rel="next"

🧚 parse

Parses a Link-header field and returns all the founded links as a list of HashRefs 😭

my @links = HTTP::Link->parse(<<EOT);
</TheBook/Chapter/2>; rel="previous", </TheBook/Chapter/4>; rel="next"
EOT
# Result:
@links = ({
    iri => '/TheBook/Chapter/2',
    relation => 'previous'
},{
    iri => '/TheBook/Chapter/4',
    relation => 'next'
});

⭐ parse_hash

Parses a Link-header field and returns all the founded links as a HashRef with IRIs as key β€” same energy, different shape πŸ’«

my %links = HTTP::Link->parse_hash(<<EOT);
</TheBook/Chapter/2>; rel="previous", </TheBook/Chapter/4>; rel="next"
EOT
# Result:
%links = (
    '/TheBook/Chapter/2' => {
        relation => 'previous'
    },
    '/TheBook/Chapter/4' => {
        relation => 'next'
    }
);

πŸ”₯ FUNCTIONS πŸ”₯

  • httplink_new β€” wrapper for HTTP::Link->"new"
  • httplink_rel β€” wrapper for HTTP::Link->"rel"
  • httplink_multi β€” wrapper for HTTP::Link->"multi"
  • httplink_parse β€” wrapper for HTTP::Link->"parse"
  • httplink_parse_hash β€” wrapper for HTTP::Link->"parse_hash"

πŸ™ˆ BUGS πŸ™ˆ

Please report any bugs or feature requests on the bugtracker website https://github.com/zurborg/libhttp-link-perl/issues

When you're submitting a bug or a request, please include a test-file or a patch to an existing test-file that illustrates the bug or the desired feature. Help us help you, bestie 🫢


πŸ‘‘ AUTHOR πŸ‘‘

David Zurborg <zurborg@cpan.org>


This software is Copyright (c) 2015 by David Zurborg.

This is free software, licensed under:

The ISC License

And that's the whole page, babes β€” this little doc dropped as part of perl v5.36.0, dated 2022-11-30, and you read the whole thing, main character energy fr fr πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from