This repository has been archived on 2025-04-28. You can view files and clone it, but cannot push or open issues or pull requests.
crystal-http-test/src/http-errors.cr
Fijxu 0002c81429
0.9.3: BUGFIX! Fix deletion of thumbnails on check_old_files job.
- Add colors to logs
- Use static table names instead of config provided ones, it's kinda
  stupid to give the user an option to set the name of the table if I'm
  developing it for sqlite
2024-11-19 22:39:23 -03:00

36 lines
690 B
Crystal

macro http_error(status_code, message)
env.response.content_type = "application/json"
env.response.status_code = {{status_code}}
error_message = {"error" => {{message}}}.to_json
error_message
end
macro error400(message)
http_error(400, {{message}})
end
macro error401(message)
http_error(401, {{message}})
end
macro error403(message)
http_error(403, {{message}})
end
macro error404(message)
http_error(404, {{message}})
end
macro error413(message)
http_error(413, {{message}})
end
macro error500(message)
http_error(500, {{message}})
end
macro msg(message)
env.response.content_type = "application/json"
msg = {"message" => {{message}}}.to_json
msg
end