summaryrefslogtreecommitdiffstats
path: root/admin/WebConsole/rest/common.php
diff options
context:
space:
mode:
authorramon <ramongomez@us.es>2017-02-10 13:30:31 +0000
committerramon <ramongomez@us.es>2017-02-10 13:30:31 +0000
commit357352b27302b3fef93367cc617647def09b04a0 (patch)
tree84caa009870e9796f417f7ecba1f069271719728 /admin/WebConsole/rest/common.php
parentf784f182cdda7f91f9e4b35157fe6bf55ba4b5af (diff)
#708: Obtener datos y código HTTP en llamadas {{{curl_multi}}} de PHP; usar fecha en formato ISO 8601 y quitar líneas en blanco al final de ficheros.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5185 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'admin/WebConsole/rest/common.php')
-rw-r--r--admin/WebConsole/rest/common.php18
1 files changed, 12 insertions, 6 deletions
diff --git a/admin/WebConsole/rest/common.php b/admin/WebConsole/rest/common.php
index 0734739f..0bb28da3 100644
--- a/admin/WebConsole/rest/common.php
+++ b/admin/WebConsole/rest/common.php
@@ -13,8 +13,6 @@
// Common functions.
-
-
/**
* @brief Compose JSON response.
* @param int status Status code for HTTP response.
@@ -130,18 +128,26 @@ function sendCommand($serverip, $serverport, $reqframe, &$values) {
}
/**
+ * @brief Show custom message for "not found" error (404).
+ */
+$app->notFound(function() {
+ echo "REST route not found.\n";
+ }
+);
+
+/**
* @brief Hook to write an error log message.
* @warning Message will be written in web server's error file.
*/
$app->hook('slim.after', function() use ($app) {
if ($app->response->getStatus() != 200 ) {
- // Compose error message (max. 50 characters from error response).
- $app->log->error(date(DATE_ATOM) . ': ' .
+ // Compose error message (truncating long lines).
+ $app->log->error(date(DATE_ISO8601) . ': ' .
$app->getName() . ' ' .
$app->response->getStatus() . ': ' .
$app->request->getMethod() . ' ' .
$app->request->getPathInfo() . ': ' .
- substr($app->response->getBody(), 0, 50));
+ substr($app->response->getBody(), 0, 100));
}
}
);
@@ -198,4 +204,4 @@ $app->get('/status', function() {
jsonResponse(200, $response);
}
);
-
+?>