|
pub async fn post( |
|
State(db): State<Database>, |
|
Json(entry): Json<Entry>, |
|
) -> Result<Json<RedirectResponse>, JsonErrorResponse> { |
|
let id = Id::rand(); |
|
let entry: write::Entry = entry.into(); |
|
let path = format!("/{}", id.to_url_path(&entry)); |
|
db.insert(id, entry).await.map_err(Error::Database)?; |
|
|
|
Ok(Json::from(RedirectResponse { path })) |
|
} |
We may try to regenerate the id and re-insert in configurable times, avoid potential weird post failure.
wastebin/crates/wastebin_server/src/handlers/insert/api.rs
Lines 40 to 50 in b63022b
We may try to regenerate the id and re-insert in configurable times, avoid potential weird post failure.