|
|
|
|
@ -1,8 +1,7 @@
|
|
|
|
|
use super::ErrorResponse; |
|
|
|
|
use axum::{ |
|
|
|
|
Json, Router, |
|
|
|
|
extract::{Path, Query, State}, |
|
|
|
|
http::StatusCode, |
|
|
|
|
response::IntoResponse, |
|
|
|
|
routing::get, |
|
|
|
|
}; |
|
|
|
|
use serde::{Deserialize, Serialize}; |
|
|
|
|
@ -16,9 +15,7 @@ pub struct EncodeQuery {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize)] |
|
|
|
|
pub struct DecodeQuery { |
|
|
|
|
pub dict: Option<String>, |
|
|
|
|
} |
|
|
|
|
pub struct DecodeQuery {} |
|
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize)] |
|
|
|
|
pub struct EncodeResponse { |
|
|
|
|
@ -39,25 +36,6 @@ pub struct DecodeResponse {
|
|
|
|
|
pub result: String, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize)] |
|
|
|
|
pub struct ErrorResponse { |
|
|
|
|
pub error: String, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl IntoResponse for ErrorResponse { |
|
|
|
|
fn into_response(self) -> axum::response::Response { |
|
|
|
|
(StatusCode::INTERNAL_SERVER_ERROR, Json(self)).into_response() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl From<anyhow::Error> for ErrorResponse { |
|
|
|
|
fn from(err: anyhow::Error) -> Self { |
|
|
|
|
Self { |
|
|
|
|
error: err.to_string(), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub async fn encode_handler( |
|
|
|
|
State(state): State<Arc<AppState>>, |
|
|
|
|
Path(input): Path<String>, |
|
|
|
|
|