Provided by: libdata-hal-perl_1.001-2_all bug

NAME

       Data::HAL - Hypertext Application Language resource

VERSION

       This document describes Data::HAL version 1.001

SYNOPSIS

           use Data::HAL qw();
           use Data::HAL::Link qw();
           {
               my $hal = Data::HAL->from_json($json_str);
               my $resource_member_data_href = $hal->resource;
               my $links_aref = $hal->links;
               my $embedded_resources_aref = $hal->embedded;
           }

           {
               my $hal = Data::HAL->new(
                   resource => {foo => 23, bar => 42},
                   links    => [Data::HAL::Link->new(relation => 'self', href => '/')],
               );

               my $json_str = $hal->as_json;
               # {
               #    "_links" : {
               #       "self" : {
               #          "href" : "/"
               #       }
               #    },
               #    "bar" : 42,
               #    "foo" : 23
               # }

               my @headers = $hal->http_headers;
               # (
               #     'Content-Type' => 'application/hal+json',
               #     'Link' => '</>;rel="self"'
               # )
           }

DESCRIPTION

       HAL is a format you can use in your hypermedia API.

   Introduction
       This section is completely quoted from the specification:

       There is an emergence of non-HTML HTTP applications ("Web APIs") which use hyperlinks to
       direct clients around their resources.

       The JSON Hypertext Application Language (HAL) is a standard which establishes conventions
       for expressing hypermedia controls, such as links, with JSON.

       HAL is a generic media type with which Web APIs can be developed and exposed as series of
       links.  Clients of these APIs can select links by their link relation type and traverse
       them in order to progress through the application.

       HAL's conventions result in a uniform interface for serving and consuming hypermedia,
       enabling the creation of general-purpose libraries that can be re-used on any API
       utilising HAL.

       The primary design goals of HAL are generality and simplicity.  HAL can be applied to many
       different domains, and imposes the minimal amount of structure necessary to cover the key
       requirements of a hypermedia Web API.

   Conformance
       The author claims to conform with <http://tools.ietf.org/html/draft-kelly-json-hal-06>,
       published 2013-10-03.

INTERFACE

   Composition
       None.

   Constructors
       "from_json"

           Data::HAL->from_json($json_str)

       Takes a HAL+JSON document as string and returns a "Data::HAL" object.

       "new"

           Data::HAL->new(
               resource => {foo => 23, bar => 42},
               links    => [Data::HAL::Link->new(relation => 'self', href => '/')]
           )

       Default Moo constructor, returns a "Data::HAL" object.

   Attributes
       "embedded"

       Type "ArrayRef[Data::HAL]", embedded resource objects <http://tools.ietf.org/html/draft-
       kelly-json-hal#section-4.1.2>

       "links"

       Type "ArrayRef[Data::HAL::Link]", link objects <http://tools.ietf.org/html/draft-kelly-
       json-hal#section-4.1.1>

       "resource"

       Type "HashRef", member data representing the current state of the resource
       <http://tools.ietf.org/html/draft-kelly-json-hal#section-4>

       "relation"

       Type Data::HAL::URI, identifier of the semantics of a link
       <http://tools.ietf.org/html/rfc5988#section-4>

       Perl strings are coerced to the Data::HAL::URI type.

       A stand-alone HAL+JSON document, when deserialised, will not have this attribute set in
       the root resource since nothing is linking to the document.

   Methods
       "TO_JSON"

       Serialisation hook for the JSON (or compatible) module.

       This method is not intended to be called directly from your code. Instead call "as_json"
       or "JSON::to_json $hal, { convert_blessed => 1 }" or similar.

       "as_json"

       Returns the resource object serialised as a HAL+JSON document string.

       "http_headers"

       Returns a list of pairs of HTTP message headers. The keys are field name strings and the
       values are field content strings. Warning: since field names can repeat, assigning this
       list to a hash loses information.

       The list is suitable as input for e.g. the "headers" accessor in HTTP::Headers or the
       "headers" attribute in Plack::Response.

       "Content-Type"

       The value is "application/hal+json", perhaps with a "profile" parameter.

       "Link"

       See "as_http_link_value" in Data::HAL::Link.

   Exports
       None.

DIAGNOSTICS

   "not a JSON object"
       The "from_json" constructor throws this exception of type
       "failure::Data::HAL::InvalidJSON" when the JSON input is a malformed HAL+JSON document.

CONFIGURATION AND ENVIRONMENT

       Requires no configuration files or environment variables.

DEPENDENCIES

       See meta file in the source distribution.

INCOMPATIBILITIES

       None reported.

BUGS AND LIMITATIONS

       Please report any bugs or feature requests to "bug-data-hal@rt.cpan.org", or through the
       web interface at <https://rt.cpan.org/Public/Dist/Display.html?Name=Data-HAL>.

   tight coupling to JSON
       It is currently difficult to exert control over the specifics of (de)serialisation,
       perhaps put the (de)serialisers into attributes?

   error type is an attribute, not a class name
       It is not worth it to design an error class hierarchy for a single error.

   Data::HAL::URI::NamespaceMap is undocumented
       It is used only internally.

TO DO

       make everything cache-friendly
       non-standard accessors for link objects
       support X8.3. cache pattern
       support HAL XML

SEE ALSO

       AtomPub <http://enwp.org/AtomPub>, the more mature, featureful hypermedia protocol

AUTHOR

       Lars DXXXXXX "<daxim@cpan.org>"

LICENCE AND COPYRIGHT

       Copyright X 2013-2019 Lars DXXXXXX "<daxim@cpan.org>"

       This library is free software; you can redistribute it and/or modify it under the same
       terms as Perl 5.18.0.

   Disclaimer of warranty
       This library is distributed in the hope that it will be useful, but without any warranty;
       without even the implied warranty of merchantability or fitness for a particular purpose.