mirror of
https://github.com/correl/urilib.git
synced 2024-11-30 19:19:56 +00:00
tcp_port() -> inet:port_number(), addressing #4
This commit is contained in:
parent
87c36905b5
commit
92da14e9d8
2 changed files with 6 additions and 9 deletions
|
@ -33,13 +33,12 @@ Type | Definition
|
||||||
`password()` | `string() | undefined`
|
`password()` | `string() | undefined`
|
||||||
`userinfo()` | `{username(), password()} | undefined`
|
`userinfo()` | `{username(), password()} | undefined`
|
||||||
`host()` | `string()`
|
`host()` | `string()`
|
||||||
`tcp_port()` | `integer()`
|
`authority()` | `{userinfo(), host(), inet:port_number()}`
|
||||||
`authority()` | `{userinfo(), host(), tcp_port()}`
|
|
||||||
`path()` | `string()`
|
`path()` | `string()`
|
||||||
`query()` | `[tuple() | string()] | undefined`
|
`query()` | `[tuple() | string()] | undefined`
|
||||||
`fragment()` | `string() | undefined`
|
`fragment()` | `string() | undefined`
|
||||||
`uri()` | `{scheme(), authority(), path(), query(), fragment()}`
|
`uri()` | `{scheme(), authority(), path(), query(), fragment()}`
|
||||||
`url()` | `{scheme(), username(), password(), host(), tcp_port(), path(), query(), fragment()}`
|
`url()` | `{scheme(), username(), password(), host(), inet:port_number(), path(), query(), fragment()}`
|
||||||
|
|
||||||
## Example Usage
|
## Example Usage
|
||||||
|
|
||||||
|
@ -48,7 +47,7 @@ Eshell V7.2.1 (abort with ^G)
|
||||||
1> urilib:build({http, {{"guest", "guest"}, "localhost", 15672}, "/api/queues", [{"name", "test"}], undefined}).
|
1> urilib:build({http, {{"guest", "guest"}, "localhost", 15672}, "/api/queues", [{"name", "test"}], undefined}).
|
||||||
"http://guest:guest@localhost:15672/api/queues?name=test"
|
"http://guest:guest@localhost:15672/api/queues?name=test"
|
||||||
|
|
||||||
2> urilib:build({http, "guest", "guest", "localhost", 15672, "/api/queues", [{"name", "test"}], undefined}).
|
2> urilib:build({http, "guest", "guest", "localhost", 15672, "/api/queues", [{"name", "test"}], undefined}).
|
||||||
"http://guest:guest@localhost:15672/api/queues?name=test"
|
"http://guest:guest@localhost:15672/api/queues?name=test"
|
||||||
|
|
||||||
3> urilib:parse("http://guest:guest@localhost:15672/api/queues?name=test").
|
3> urilib:parse("http://guest:guest@localhost:15672/api/queues?name=test").
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
-export_type([scheme/0,
|
-export_type([scheme/0,
|
||||||
host/0,
|
host/0,
|
||||||
tcp_port/0,
|
|
||||||
username/0,
|
username/0,
|
||||||
password/0,
|
password/0,
|
||||||
userinfo/0,
|
userinfo/0,
|
||||||
|
@ -37,16 +36,15 @@
|
||||||
-type hexcase() :: uppercase | lowercase.
|
-type hexcase() :: uppercase | lowercase.
|
||||||
-type scheme() :: http | https | atom().
|
-type scheme() :: http | https | atom().
|
||||||
-type host() :: string().
|
-type host() :: string().
|
||||||
-type tcp_port() :: integer().
|
|
||||||
-type username() :: string() | undefined.
|
-type username() :: string() | undefined.
|
||||||
-type password() :: string() | undefined.
|
-type password() :: string() | undefined.
|
||||||
-type userinfo() :: {username(), password()} | undefined.
|
-type userinfo() :: {username(), password()} | undefined.
|
||||||
-type authority() :: {userinfo(), host(), tcp_port()}.
|
-type authority() :: {userinfo(), host(), inet:port_number()}.
|
||||||
-type path() :: string().
|
-type path() :: string().
|
||||||
-type query() :: [tuple() | string()] | undefined.
|
-type query() :: [tuple() | string()] | undefined.
|
||||||
-type fragment() :: string() | undefined.
|
-type fragment() :: string() | undefined.
|
||||||
-type uri() :: {scheme(), authority(), path(), query(), fragment()}.
|
-type uri() :: {scheme(), authority(), path(), query(), fragment()}.
|
||||||
-type url() :: {scheme(), username(), password(), host(), tcp_port(), path(), query(), fragment()}.
|
-type url() :: {scheme(), username(), password(), host(), inet:port_number(), path(), query(), fragment()}.
|
||||||
|
|
||||||
-spec build(Value :: uri() | url()) -> string().
|
-spec build(Value :: uri() | url()) -> string().
|
||||||
%% @doc Build a URI
|
%% @doc Build a URI
|
||||||
|
@ -247,7 +245,7 @@ url_maybe_add_userinfo(Username, Password, URL) ->
|
||||||
string:concat(URL, string:concat(string:join([Username, Password], ":"), "@")).
|
string:concat(URL, string:concat(string:join([Username, Password], ":"), "@")).
|
||||||
|
|
||||||
|
|
||||||
-spec url_add_host_and_port(scheme(), host(), tcp_port(), string()) -> string().
|
-spec url_add_host_and_port(scheme(), host(), inet:port_number(), string()) -> string().
|
||||||
%% @private
|
%% @private
|
||||||
url_add_host_and_port(undefined, Host, undefined, URL) ->
|
url_add_host_and_port(undefined, Host, undefined, URL) ->
|
||||||
string:concat(URL, Host);
|
string:concat(URL, Host);
|
||||||
|
|
Loading…
Reference in a new issue