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);
|
||||
|
||||
if ($row) {
|
||||
$c->delay(sub {
|
||||
my ($delay) = @_;
|
||||
$c->eval->get_eval($pasteid, $row->{paste}, [$row->{language}], $delay->begin(0, 1))
|
||||
},
|
||||
sub {
|
||||
my ($delay, $output_hr) = @_;
|
||||
|
||||
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 => $row->{language},
|
||||
output => $c->eval->get_eval($pasteid, $row->{paste}, $row->{language})
|
||||
language => $output_lang,
|
||||
output => $output
|
||||
warning => "If this was multi-language paste, you just got a random language",
|
||||
};
|
||||
|
||||
$c->render(json => $data);
|
||||
});
|
||||
} else {
|
||||
# 404
|
||||
return $c->reply->not_found;
|
||||
|
|
Loading…
Add table
Reference in a new issue