#include "../routes.h" #include "../../numberhelper.h" #include "../../servehelper.h" #include "../../pixivclient.h" #include "common.h" void users_route(const httplib::Request& req, httplib::Response& res, const Config& config, PixivClient& pixiv_client) { uint64_t user_id = to_ull(req.matches[1].str()); User user; try { user = pixiv_client.get_user(user_id); } catch (const PixivException& e) { if (e.status == 404) { res.status = 404; serve_error(req, res, config, "404: User not found", e.what()); } else { res.status = 500; serve_error(req, res, config, "500: Internal server error", "Failed to fetch user information", e.what()); } return; } catch (const std::exception& e) { res.status = 500; serve_error(req, res, config, "500: Internal server error", "Failed to fetch user information", e.what()); return; } serve(req, res, config, user.display_name + " (@" + user.username + ')', generate_user_header(user, config)); }