mirror of
https://github.com/perlbot/perlbuut-pastebin
synced 2025-06-07 14:17:26 -04:00
Fix the API
This commit is contained in:
parent
c9a995ef18
commit
9f491dba38
1 changed files with 20 additions and 9 deletions
|
@ -28,16 +28,27 @@ sub api_get_paste {
|
||||||
my $row = $c->paste->get_paste($pasteid);
|
my $row = $c->paste->get_paste($pasteid);
|
||||||
|
|
||||||
if ($row) {
|
if ($row) {
|
||||||
my $data = {
|
$c->delay(sub {
|
||||||
paste => $row->{paste},
|
my ($delay) = @_;
|
||||||
when => $row->{when},
|
$c->eval->get_eval($pasteid, $row->{paste}, [$row->{language}], $delay->begin(0, 1))
|
||||||
username => $row->{who},
|
},
|
||||||
description => $row->{desc},
|
sub {
|
||||||
language => $row->{language},
|
my ($delay, $output_hr) = @_;
|
||||||
output => $c->eval->get_eval($pasteid, $row->{paste}, $row->{language})
|
|
||||||
};
|
|
||||||
|
|
||||||
$c->render(json => $data);
|
my ($output_lang) = keys %$output_hr; # grab a random output value, should be the first one since multilang support isn't working yet
|
||||||
|
my ($output) = $output_hr->{$output_lang};
|
||||||
|
my $data = {
|
||||||
|
paste => $row->{paste},
|
||||||
|
when => $row->{when},
|
||||||
|
username => $row->{who},
|
||||||
|
description => $row->{desc},
|
||||||
|
language => $output_lang,
|
||||||
|
output => $output
|
||||||
|
warning => "If this was multi-language paste, you just got a random language",
|
||||||
|
};
|
||||||
|
|
||||||
|
$c->render(json => $data);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
# 404
|
# 404
|
||||||
return $c->reply->not_found;
|
return $c->reply->not_found;
|
||||||
|
|
Loading…
Add table
Reference in a new issue