Пример #1
0
header('Content-Type: text/javascript; charset=utf8');
header('Access-Control-Allow-Origin: ' . $base_url . '/');
header('Access-Control-Max-Age: 3628800');
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE');
with('/api/version', function () {
    respond('GET', '/?', function ($request, $response) {
        global $api_version, $app_version, $webapp_version;
        $version = ['api_version' => $api_version, 'app_version' => $app_version, 'webapp_version' => $webapp_version];
        $output = json_encode($version, JSON_PRETTY_PRINT);
        echo $output;
    });
});
with('/api/category', function () {
    respond('GET', '/?', function ($request, $response) {
        $list = new UserList();
        $selection = $list->getCategories(20);
        $output = json_encode($selection, JSON_PRETTY_PRINT);
        echo $output;
    });
    respond('GET', '/[:id]', function ($request, $response) {
        // Show items from a single category
        $id = $request->id;
        $list = new UserList();
        $selection = $list->getCategoriesList(20, $id);
        $output = json_encode($selection, JSON_PRETTY_PRINT);
        echo $output;
    });
});
with('/api/items', function () {
    respond('GET', '/?', function ($request, $response) {
        $list = new UserList();
Пример #2
0
 public function testListing()
 {
     $selection = UserList::getCategories(20);
     $this->assertEquals(count($selection), 6);
 }