Current section
Files
Jump to
Current section
Files
src/go_over@hex@puller.erl
-module(go_over@hex@puller).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-define(FILEPATH, "src/go_over/hex/puller.gleam").
-export([run/2]).
-export_type([puller/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(false).
-type puller() :: c_u_r_l | w_g_e_t | h_t_t_p_i_e | {mock, binary()}.
-file("src/go_over/hex/puller.gleam", 12).
?DOC(false).
-spec run(puller(), binary()) -> {ok, binary()} | {error, {integer(), binary()}}.
run(Puller, Url) ->
case Puller of
c_u_r_l ->
go_over@util@util:retry_cmd(<<"curl"/utf8>>, [<<"-sf"/utf8>>, Url]);
w_g_e_t ->
go_over@util@util:retry_cmd(<<"wget"/utf8>>, [<<"-qO-"/utf8>>, Url]);
h_t_t_p_i_e ->
go_over@util@util:retry_cmd(
<<"https"/utf8>>,
[<<"--body"/utf8>>, Url]
);
{mock, Result_filepath} ->
_pipe = simplifile:read(Result_filepath),
gleam@result:replace_error(_pipe, {1, <<"Mock Failure"/utf8>>})
end.