From 35e23d428cd466b7a81f3fac3d21f346d258506a Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Tue, 8 Jan 2013 22:16:04 +0100 Subject: [PATCH] brmd.pl: Add support for the SpaceAPI json output; code provided by ruza --- brmd/brmd.pl | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/brmd/brmd.pl b/brmd/brmd.pl index 2fe953e..ce1488c 100755 --- a/brmd/brmd.pl +++ b/brmd/brmd.pl @@ -279,6 +279,7 @@ sub new { "/brmstatus.png" => \&web_brmstatus_png, "/brmstatus.txt" => \&web_brmstatus_txt, "/brmstatus-switch" => sub { $self->web_brmstatus_switch(@_) }, + "/brmstatus.json" => \&web_brmstatus_json, "/alphasign" => \&web_alphasign_text, "/alphasign-set" => \&web_alphasign_set, "/" => \&web_index @@ -354,7 +355,7 @@ sub web_index {

brmd web interface

Enjoy the view!

@@ -415,6 +416,46 @@ EOT return RC_OK; } +sub web_brmstatus_json { + my ($request, $response) = @_; + + $response->protocol("HTTP/1.0"); + $response->code(RC_OK); + $response->push_header("Content-Type", "application/json"); + $response->push_header("Access-Control-Allow-Origin", "*"); + disable_caching($response); + + $response->content(<