Search documentation of jhn_stdlib

# jhn_uri (jhn_stdlib v5.10.3)

View Source

A URI library based on: Uniform Resource Identifier (URI): Generic Syntax (rfc3986)

# Summary

## Types

opt/0
opts/0
scheme/0
uri/0

## Functions

decode(Binary)

Decodes the binary into a structured Erlang term. Equivalent of decode(Binary, []) -> URI.

decode(Binary, Opts)

Decodes the binary into a structured Erlang. Decode will give an exception if the binary is not well formed URI. Options are

encode(Term)

Encodes the structured Erlang term as an iolist. Equivalent of encode(Term, []) -> URI.

encode(Term, Opts)

Encodes the structured Erlang term as an iolist or binary. Encode will give an exception if the erlang term is not well formed. Options are: binary -> a binary is returned list -> a flat list is returned iolist -> a iolist is returned ipv4 -> an ipv4 address is encoded when the Host is an integer ipv6 -> an ipv6 address is encoded when the Host is an integer ipv6ipv4 -> encoded IPv6 host address has the two least sigificant segments repesented in IPv4 address format compact -> the most compact encoding of IPv6 used (collapsed zeros)

# Types

# opt/0

    -type opt() :: ipv4 | ipv6 | ipv6ipv4 | compact | iolist | list | binary.

# opts/0

    -type opts() :: [opt()].

# scheme/0

    -type scheme() :: http | https | file | sip | sips | mailto | ws | wss | atom().

# uri/0

    -type uri() ::
              #uri{scheme :: undefined | scheme(),
                   userinfo :: [binary()],
                   host :: undefined | binary() | inet:ip_address(),
                   port :: undefined | inet:port_number(),
                   path :: [binary()],
                   query :: binary(),
                   fragment :: binary()}.

# Functions

# decode(Binary)

    -spec decode(binary()) -> uri().

Decodes the binary into a structured Erlang term. Equivalent of decode(Binary, []) -> URI.

# decode(Binary, Opts)

    -spec decode(binary(), opts()) -> uri().

Decodes the binary into a structured Erlang. Decode will give an exception if the binary is not well formed URI. Options are:

# encode(Term)

    -spec encode(uri()) -> iolist().

Encodes the structured Erlang term as an iolist. Equivalent of encode(Term, []) -> URI.

# encode(Term, Opts)

    -spec encode(uri(), opts()) -> iolist() | binary().

Encodes the structured Erlang term as an iolist or binary. Encode will give an exception if the erlang term is not well formed. Options are: binary -> a binary is returned list -> a flat list is returned iolist -> a iolist is returned ipv4 -> an ipv4 address is encoded when the Host is an integer ipv6 -> an ipv6 address is encoded when the Host is an integer ipv6ipv4 -> encoded IPv6 host address has the two least sigificant segments repesented in IPv4 address format compact -> the most compact encoding of IPv6 used (collapsed zeros)