Exemplo n.º 1
0
    respond('POST', '/[:user]/[:id]', function ($request, $response) {
        $categoryid = $request->id;
        $userid = $request->user;
        $list = new UserList();
        $save = $list->addUserCategory($categoryid, $userid);
    });
});
with('/api/usercategories/delete', function () {
    respond('POST', '/[:user]/[:id]', function ($request, $response) {
        $categoryid = $request->id;
        $userid = $request->user;
        $list = new UserList();
        $save = $list->deleteUserCategory($categoryid, $userid);
    });
});
with('/api/usercategories/list', function () {
    respond('GET', '/[:user]', function ($request, $response) {
        $userid = $request->user;
        $list = new UserList();
        $save = $list->getUserCategories($userid);
        $output = json_encode($save, JSON_PRETTY_PRINT);
        echo $output;
    });
});
with('/api', function () {
    respond('GET', '/', function ($request, $response) {
        header('Content-Type: text/html; charset=utf8');
        require_once 'api.html';
    });
});
dispatch();