Added auth

This commit is contained in:
Connor Johnstone
2026-03-19 14:02:33 -04:00
parent 93392db27c
commit 421ec3199b
21 changed files with 719 additions and 26 deletions
+8
View File
@@ -15,6 +15,12 @@ pub enum ApiError {
#[error("bad request: {0}")]
BadRequest(String),
#[error("unauthorized: {0}")]
Unauthorized(String),
#[error("forbidden: {0}")]
Forbidden(String),
#[error("rate limited: {0}")]
TooManyRequests(String),
@@ -27,6 +33,8 @@ impl ResponseError for ApiError {
let (status, message) = match self {
ApiError::NotFound(msg) => (actix_web::http::StatusCode::NOT_FOUND, msg.clone()),
ApiError::BadRequest(msg) => (actix_web::http::StatusCode::BAD_REQUEST, msg.clone()),
ApiError::Unauthorized(msg) => (actix_web::http::StatusCode::UNAUTHORIZED, msg.clone()),
ApiError::Forbidden(msg) => (actix_web::http::StatusCode::FORBIDDEN, msg.clone()),
ApiError::TooManyRequests(msg) => {
tracing::warn!(error = %msg, "rate limited");
(actix_web::http::StatusCode::TOO_MANY_REQUESTS, msg.clone())