From 752c59413b4899b295a9359eaef98dc9efb01533 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Thu, 29 Aug 2013 18:01:24 +0200 Subject: Add GET parameter for json output Signed-off-by: Florian Pritz --- application/core/MY_Controller.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'application/core') diff --git a/application/core/MY_Controller.php b/application/core/MY_Controller.php index 09b813b71..4c0fa278c 100644 --- a/application/core/MY_Controller.php +++ b/application/core/MY_Controller.php @@ -32,12 +32,18 @@ class MY_Controller extends CI_Controller { mb_internal_encoding('UTF-8'); $this->load->helper(array('form', 'filebin')); + // TODO: proper accept header handling or is this enough? if (isset($_SERVER["HTTP_ACCEPT"])) { if ($_SERVER["HTTP_ACCEPT"] == "application/json") { request_type("json"); } } + // Allow for easier testing in browser + if ($this->input->get("json") !== false) { + request_type("json"); + } + if (request_type() == "json" && ! in_array($this->uri->rsegment(2), $this->json_enabled_functions)) { show_error("Function not JSON enabled"); } -- cgit v1.2.3-24-g4f1b