2
0
mirror of https://github.com/boostorg/website.git synced 2026-01-26 19:12:15 +00:00
Files
website/doc/libraries.json.php
Daniel James b8120cc53c Adjust a lot of the error handling.
Use exceptions for most internal errors. Return error codes for most errors.
2016-09-29 02:08:52 +01:00

30 lines
918 B
PHP

<?php
require_once(__DIR__.'/../common/code/bootstrap.php');
if (isset($_GET['version'])) {
try {
$version = BoostVersion::from($_GET['version']);
}
catch (BoostVersion_Exception $e) {
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
echo json_encode(Array(
'error' => $e->getMessage(),
));
exit(0);
}
} else {
$version = BoostVersion::current();
}
// TODO: This is a bit awkard, should probably have an alternative
// to 'get_for_version' which returns a BoostLibraries instance
// rather than an array.
// TODO: Include hidden libraries.
$version_libs = array_map(function($lib) { return new BoostLibrary($lib); },
BoostLibraries::load()->get_for_version($version));
header('Content-type: application/json');
echo BoostLibrary::get_libraries_json($version_libs);
echo $version_libs->to_json();