---
name: "Data::HAL::Link"
section: "3pm"
platform: "linux"
package: "libdata-hal-perl"
version: "1.001-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Data::HAL::Link"
---

# Data::HAL::Link(3pm)

Hypertext Application Language link

## NAME

Data::HAL::Link - Hypertext Application Language link

## VERSION

This document describes Data::HAL::Link version 1.001

## SYNOPSIS

```
    map { +{
        href => $_->href->uri->as_string,
        rel  => $_->relation->uri->as_string
    } } @{ $resource->links }
```

## DESCRIPTION

This section is completely quoted from the specification:

A Link Object represents a hyperlink from the containing resource to a URI.

## INTERFACE

### Composition

None.

### Constructors

*"new"*

When the "deprecation" attribute is set, the constructor logs a Log::Any warning:

`"The link (relation: "%s", href: "%s") is deprecated, see <%s>"`

You can consume it with a Log::Any::Adapter of your choice, e.g.

```
    use Log::Any::Adapter 'Stderr';
```

Otherwise the constructor behaves like the default Moo constructor. Returns a `"Data::HAL::Link"` object.

### Attributes

Perl strings are coerced to the Data::HAL::URI type in the attributes "relation", "href", "deprecation", "profile".

*"relation"*

Type Data::HAL::URI, **required**, link relation \<http://tools.ietf.org/html/draft-kelly-json-hal#section-8.2\>

*"href"*

Type Data::HAL::URI, **required**, link target URI or URI template \<http://tools.ietf.org/html/draft-kelly-json-hal#section-5.1\>

*"templated"*

Type boolean, whether `"href"` is a URI template \<http://tools.ietf.org/html/draft-kelly-json-hal#section-5.2\>

Perl boolean values are coerced to the boolean type.

*"type"*

Type MIME::Type, media type of the `"href"` resource \<http://tools.ietf.org/html/draft-kelly-json-hal#section-5.3\>

*"deprecation"*

Type Data::HAL::URI, if existing indicates the link is deprecated \<http://tools.ietf.org/html/draft-kelly-json-hal#section-5.4\>

Setting the attribute triggers a log message in the constructor "new".

*"name"*

Type `"Str"`, secondary key for selecting link objects which share the same relation type \<http://tools.ietf.org/html/draft-kelly-json-hal#section-5.5\>

*"profile"*

Type Data::HAL::URI, RFC 6906 profile of the target resource \<http://tools.ietf.org/html/draft-kelly-json-hal#section-5.6\>

*"title"*

Type `"Str"`, labels the link with a human-readable identifier \<http://tools.ietf.org/html/draft-kelly-json-hal#section-5.7\>

*"hreflang"*

Type `"Str"`, indicates the language of the target resource \<http://tools.ietf.org/html/draft-kelly-json-hal#section-5.8\>

### Methods

*"as\_http\_link\_value"*

Returns the link as a RFC 5988 `"link-value"` \<http://tools.ietf.org/html/rfc5988#section-5\> string, e.g. `"</orders?page=2>;rel="next""`.

### Exports

None.

## DIAGNOSTICS

See "new" constructor.

## CONFIGURATION AND ENVIRONMENT

Requires no configuration files or environment variables.
