HTTP::Link(3pm)
β¨ 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β seenewabove, bestie.$relationβ will be appended to%optionsbyrelation =$relation >> π$extensionβ will be appended to%optionsbyextension =$extension >>%optionsβ seenew.
π 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 forHTTP::Link->"new"httplink_relβ wrapper forHTTP::Link->"rel"httplink_multiβ wrapper forHTTP::Link->"multi"httplink_parseβ wrapper forHTTP::Link->"parse"httplink_parse_hashβ wrapper forHTTP::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>
π COPYRIGHT AND LICENSE π
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
- debian bookworm: libhttp-link-perl 0.001-3 Β· ISC
- debian trixie: libhttp-link-perl 0.001-3 Β· ISC
- ubuntu noble: libhttp-link-perl 0.001-3 Β· ISC
- ubuntu resolute: libhttp-link-perl 0.001-3 Β· ISC
- ubuntu stonking: libhttp-link-perl 0.001-3 Β· ISC
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms