json_http.hpp 373 B

12345678910111213
  1. #pragma once
  2. #include <httplib.h>
  3. #include <nlohmann/json.hpp>
  4. namespace svapi {
  5. // Parse a request body as JSON; throws ApiError(BadRequest) on failure.
  6. nlohmann::json bodyJson(const httplib::Request& req);
  7. // Serialize and send a JSON response with the given status.
  8. void sendJson(httplib::Response& res, int status, const nlohmann::json& body);
  9. } // namespace svapi