From b297499e13ce24806cc354ea601292b30cbb979f Mon Sep 17 00:00:00 2001 From: michael-coles Date: Wed, 6 Dec 2017 15:04:31 +0100 Subject: Add support for unix sockets --- src/gun.erl | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/gun.erl') diff --git a/src/gun.erl b/src/gun.erl index be9e15d..a584e01 100644 --- a/src/gun.erl +++ b/src/gun.erl @@ -17,6 +17,7 @@ %% Connection. -export([open/2]). -export([open/3]). +-export([open_unix/2]). -export([info/1]). -export([close/1]). -export([shutdown/1]). @@ -132,6 +133,14 @@ open(Host, Port) -> -spec open(inet:hostname(), inet:port_number(), opts()) -> {ok, pid()} | {error, any()}. open(Host, Port, Opts) when is_list(Host); is_atom(Host) -> + do_open(Host, Port, Opts). + +-spec open_unix(Path::string(), opts()) + -> {ok, pid()} | {error, any()}. +open_unix(SocketPath, Opts) -> + do_open({local, SocketPath}, 0, Opts). + +do_open(Host, Port, Opts) -> case check_options(maps:to_list(Opts)) of ok -> case supervisor:start_child(gun_sup, [self(), Host, Port, Opts]) of -- cgit v1.2.3