Module euri

Data Types

args()

args() = #{scheme => nonempty_string() | nonempty_binary(), host => nonempty_string() | nonempty_binary(), port => non_neg_integer(), path => path(), query => query()}

nonempty_binary()

nonempty_binary() = <<_:8, _:_*8>>

option()

option() = relative

path()

path() = string() | binary() | [nonempty_string() | nonempty_binary()]

query()

query() = [{Key::atom() | nonempty_string() | nonempty_binary(), Value::boolean() | integer() | string() | nonempty_binary()}]

uri()

abstract datatype: uri()

Function Index

new/0Create a new, "empty" URI.
new/1Create a URI from args().
to_binary/1Same as to_string/1 but returns a binary().
to_binary/2Same as to_string/2 but returns a binary().
to_string/1Turn a uri() into a string().
to_string/2Turn a uri() into a string() with some options.

Function Details

new/0

new() -> uri()

Create a new, "empty" URI.

This will default to an uri pointing to https://localhost. In other words, the scheme will be set to https, the port to 443, the host to localhost and both the path and the query will be left empty.

This is equivalent to calling euri:new(#{}).

new/1

new(Args::args()) -> uri()

Create a URI from args().

Note that all the values in args() are optional. When not supplied, defaults will be used: scheme defaults to https, host defaults to localhost, port to 443 and the path and query are left empty when not supplied.

to_binary/1

to_binary(U::uri()) -> nonempty_binary()

Same as to_string/1 but returns a binary().

to_binary/2

to_binary(U::uri(), Opts::[option()]) -> nonempty_binary()

Same as to_string/2 but returns a binary().

to_string/1

to_string(U::uri()) -> nonempty_string()

Turn a uri() into a string().

By default, this will be an absolute URL including the scheme, hostname and port (unless the port is the default port for the given scheme).

     Uri = euri:new(),
     "https://localhost" = euri:to_string(Uri).
 
     Uri = euri:new(#{host => "neverssl.com", scheme => "http"}).
     "http://neverssl.com" = euri:to_string(Uri).
This is equivalent to calling euri:to_string(Uri, []).

to_string/2

to_string(U::uri(), Opts::[option()]) -> nonempty_string()

Turn a uri() into a string() with some options.

Currently, the only option() is relative which will make this function return an URL relative to the root of the hostname.


Generated by EDoc