HTTP::Link3pm
Rfc5988 web linking
Version
version 0.001
Methods
new
Return a new Web Link as string
my $link = HTTP::Link->new('/TheBook/Chapter/2',relation => 'next',title => 'next chapter',);# Result:# </TheBook/Chapter/2>; rel="next"; title="next chapter"
Arguments:
•
|
|
|---|---|
•
|
|
Parameters for %options:
- •
-
"relation"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)
- •
-
"extension"An extension for a relation type.
- •
-
"anchor"An anchor for the context IRI.
- •
-
"hreflang"A hint indicating what the language of the destination's content is
- •
-
"media"Intended destination medium, like in a CSS media query.
- •
-
"title"A human-readable label. This will be encoded with MIME::EcoEncode.
- •
-
"type"A hint indication the most possible MIME type of the destination's content.
rel
Shortcut method for "new" with a different signature:
HTTP::Link->rel('/TheBook/Chapter/2',start => '/TheBook/Chapter/0');# same asHTTP::Link->new('/TheBook/Chapter/2',relation => 'start',extension => '/TheBook/Chapter/0',);
Arguments:
- •
-
$iriSee "new"
- •
-
$relationWill appended to
%optionsby" relation ="$relation>>
- •
-
$extensionWill appended to
%optionsby" extension ="$extension>>
- •
-
%optionsSee "new"
multi
When more than one link should be provides, this method is useful. 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 a returns all 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 a returns all founded links as a HashRef with IRIs as key:
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"
Copyright and license
This software is Copyright (c) 2015 by David Zurborg.
This is free software, licensed under:
The ISC License
Releases
Unchanged in 2 releases since Debian 12 (Bookworm).