diff options
| author | jules <jules@okfoc.us> | 2014-01-13 12:20:24 -0500 |
|---|---|---|
| committer | jules <jules@okfoc.us> | 2014-01-13 12:20:24 -0500 |
| commit | 9d37bced7dd4873f32f1374d2914e27bb984c422 (patch) | |
| tree | 7f5985c12fc553e6bcc5ccf3ce51adc110d77357 /cgi-bin/view | |
| parent | 7866e46307c22997a9f4ce5a577a5f4c43531015 (diff) | |
view: support jsonp callback
Diffstat (limited to 'cgi-bin/view')
| -rwxr-xr-x | cgi-bin/view | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/cgi-bin/view b/cgi-bin/view index 526d268..3994117 100755 --- a/cgi-bin/view +++ b/cgi-bin/view @@ -53,6 +53,7 @@ sub main{ $params->{$key} = $value; } + my $callback = $params->{'callback'} || undef unless(defined $params->{f}){ not_specified_error("f"); @@ -90,11 +91,23 @@ sub main{ $res = mysql_retrieve('select shaders.* from shader_ids cross join shaders on shader_ids.id = shaders.shader_id'); } default { - print $json->pretty->encode ({ ERROR => "Function parameter f improperly defined"}); + if (defined $callback) { + print $callback + "("; + print $json->pretty->encode ({ ERROR => "Function parameter f improperly defined"}); + print ")"; + } + else { + print $json->pretty->encode ({ ERROR => "Function parameter f improperly defined"}); + } exit(1); }; } - print $res; + if (defined $callback) { + print $callback + "(" + $res + ")"; + } + else { + print $res; + } } main(); exit(0); |
