Skip to content

Commit

Permalink
api fixes for upcoming ecosystem
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-o committed Sep 4, 2024
1 parent 49f3c53 commit 33b2d5f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
20 changes: 5 additions & 15 deletions lib/Fez/API.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -296,21 +296,11 @@ Uploads a dist to the fez|zef ecosystem
returns: _api-response_
}
sub direct-upload(Str:D $api-key, IO() $file where *.f --> Fez::Types::api-response) is export {
try {
CATCH {
default {
return Fez::Types::api-response.new(
:!success,
:message($_.message),
);
}
}
Fez::Types::api-response.new:
|post('/upload',
:headers({:Authorization("Zef {$api-key}")}),
:file($file.absolute)
);
};
Fez::Types::api-response.new:
|post('/upload',
:headers({:Authorization("Zef {$api-key}")}),
:file($file.absolute)
);
}

#`{md
Expand Down
2 changes: 1 addition & 1 deletion lib/Fez/Util/Curl.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ method get($url, :%headers = ()) {
method post($url, :$method = 'POST', :$data = '', :$file = '', :%headers = ()) {
my @args = ('curl', '-vs', '-X', $method);
@args.push('-d', $data) if $data;
@args.push('-T', $file) if $file;
@args.push('-F', "dist=\@{$file}") if $file;
@args.push('-H', "$_: {%headers{$_}}") for %headers.keys;
@args.push($url);

Expand Down
5 changes: 4 additions & 1 deletion lib/Fez/Util/Wget.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ method get($url, :%headers = ()) {
method post($url, :$method = 'POST', :$data = '', :$file = '', :%headers = ()) {
my @args = ('wget', '--method', $method, '-O-');
@args.push('--body-data', $data) if $data;
@args.push('--body-file', $file) if $file;

@args.push('--header', "$_: {%headers{$_}}") for %headers.keys;
if $file {
@args.push('--header', 'Content-Type: multipart/form-data boundary=FILEUPLOAD');
@args.push('--body-file', $file);
}
@args.push($url);

my ($rc, $out, $err) = run-p('WGET', |@args);
Expand Down

0 comments on commit 33b2d5f

Please sign in to comment.