aboutsummaryrefslogtreecommitdiffstats
path: root/include/nms/web.pm
diff options
context:
space:
mode:
authorKristian Lyngstol <kristian@bohemians.org>2016-03-27 08:27:17 +0200
committerKristian Lyngstol <kristian@bohemians.org>2016-03-27 08:27:17 +0200
commit1d2470a411e5eaac7e5a1c5d5b6b81e92c92f4a8 (patch)
tree54b901757b088d54d33e70f28a6203383b4dc844 /include/nms/web.pm
parent0a230ac5481b9518abc64181dbbb4509d83c0b89 (diff)
parent96a9bb4c42f4b53020302fea2a46e734c61c0319 (diff)
Merge branch 'master' of github.com:tech-server/tgmanage
Diffstat (limited to 'include/nms/web.pm')
-rwxr-xr-xinclude/nms/web.pm13
1 files changed, 10 insertions, 3 deletions
diff --git a/include/nms/web.pm b/include/nms/web.pm
index 2a5e132..889e774 100755
--- a/include/nms/web.pm
+++ b/include/nms/web.pm
@@ -57,14 +57,19 @@ sub db_safe_quote {
# endpoints it is better to return no data than old data (e.g.: ping).
sub setwhen {
$now = "now()";
- my $window = '15m';
- if (@_ == 1) {
+ my $window = '8m';
+ my $offset = '0s';
+ if (@_ > 0) {
$window = $_[0];
}
+ if (@_ > 1) {
+ $offset = $_[1];
+ }
if (defined($get_params{'now'})) {
$now = db_safe_quote('now') . "::timestamp ";
$cc{'max-age'} = "3600";
}
+ $now = "(" . $now . " - '" . $offset . "'::interval)";
$when = " time > " . $now . " - '".$window."'::interval and time < " . $now . " ";
}
@@ -81,7 +86,9 @@ sub finalize_output {
printcc;
print "Etag: $hash\n";
- print "Content-Type: text/jso; charset=utf-8\n\n";
+ print "Access-Control-Allow-Origin: *\n";
+ print "Access-Control-Allow-Methods: HEAD, GET\n";
+ print "Content-Type: text/json; charset=utf-8\n\n";
print JSON::XS::encode_json(\%json);
print "\n";
}