public function doGet() { try { $this->noHeaders = true; $context = new GadgetContext('GADGET'); $makeRequestParams = MakeRequestOptions::fromCurrentRequest(); $makeRequestHandler = new MakeRequestHandler($context); $makeRequestHandler->fetchJson($makeRequestParams); } catch (MakeRequestParameterException $e) { // Something was misconfigured in the request header("HTTP/1.0 400 Bad Request", true); echo "<html><body><h1>400 - Bad request</h1><p>" . $e->getMessage() . "</body></html>"; } catch (Exception $e) { // catch all exceptions and give a 500 server error header("HTTP/1.0 500 Internal Server Error"); echo "<html><body><h1>Internal server error</h1><p>" . $e->getMessage() . "</p></body></html>"; } }