From a644ecfd0fb67870ac3f3a13476aa0accec74d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sun, 3 Jun 2018 08:11:07 +0200 Subject: Fill in the options types instead of using map() --- doc/src/manual/gun.asciidoc | 2 +- src/gun.erl | 31 ++++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/doc/src/manual/gun.asciidoc b/doc/src/manual/gun.asciidoc index 77253ba..45f65ab 100644 --- a/doc/src/manual/gun.asciidoc +++ b/doc/src/manual/gun.asciidoc @@ -150,7 +150,7 @@ opts() :: #{ retry_timeout => pos_integer(), trace => boolean(), transport => tcp | ssl, - transport_opts => [gen_tcp:connect_option()] | [ssl:connect_option()] + transport_opts => [gen_tcp:connect_option()] | [ssl:connect_option()], ws_opts => ws_opts() } ---- diff --git a/src/gun.erl b/src/gun.erl index bad1418..badd691 100644 --- a/src/gun.erl +++ b/src/gun.erl @@ -91,21 +91,42 @@ | {text | binary | close | ping | pong, iodata()} | {close, ws_close_code(), iodata()}. --type opts() :: map(). +-type opts() :: #{ + connect_timeout => timeout(), + http_opts => http_opts(), + http2_opts => http2_opts(), + protocols => [http | http2], + retry => non_neg_integer(), + retry_timeout => pos_integer(), + trace => boolean(), + transport => tcp | ssl, + transport_opts => [gen_tcp:connect_option()] | [ssl:connect_option()], + ws_opts => ws_opts() +}. -export_type([opts/0]). %% @todo Add an option to disable/enable the notowner behavior. --type req_opts() :: map(). +-type req_opts() :: #{ + reply_to => pid() +}. -export_type([req_opts/0]). --type http_opts() :: map(). +-type http_opts() :: #{ + keepalive => timeout(), + transform_header_name => fun((binary()) -> binary()), + version => 'HTTP/1.1' | 'HTTP/1.0' +}. -export_type([http_opts/0]). --type http2_opts() :: map(). +-type http2_opts() :: #{ + keepalive => timeout() +}. -export_type([http2_opts/0]). %% @todo keepalive --type ws_opts() :: map(). +-type ws_opts() :: #{ + compress => boolean() +}. -export_type([ws_opts/0]). -record(state, { -- cgit v1.2.3