1
0
mirror of https://github.com/cydrobolt/polr.git synced 2024-11-09 19:52:28 +01:00

Add updated_at, created_at for lookup; add appropriate Content-Type headers fix #211, fix #210

This commit is contained in:
Chaoyi Zha 2016-08-28 15:29:48 -07:00
parent 0fd1f44232
commit fbb6568042
2 changed files with 8 additions and 4 deletions

View File

@ -51,15 +51,17 @@ class ApiController extends Controller {
];
if ($response_type == 'json') {
return json_encode($response);
return response(json_encode($response))
->header('Content-Type', 'application/json');
}
else {
if ($plain_text_response) {
// return alternative plain text response if provided
return $plain_text_response;
$result = $plain_text_response;
}
// assume plain text if json not requested
return $result;
return response($result)
->header('Content-Type', 'text/plain');
}
}
}

View File

@ -60,7 +60,9 @@ class ApiLinkController extends ApiController {
return self::encodeResponse([
'long_url' => $link['long_url'],
'created_at' => $link['created_at'],
'clicks' => $link['clicks']
'clicks' => $link['clicks'],
'updated_at' => $link['updated_at'],
'created_at' => $link['created_at']
], 'lookup', $response_type, $link['long_url']);
}
else {