Handle DELETE /databases/:db/tables/:table - drop a table.
(
Path((db, table)): Path<(String, String)>,
Extension(state): Extension<Arc<RESTServer>>,
)
| 421 | |
| 422 | /// Handle DELETE /databases/:db/tables/:table - drop a table. |
| 423 | pub async fn drop_table( |
| 424 | Path((db, table)): Path<(String, String)>, |
| 425 | Extension(state): Extension<Arc<RESTServer>>, |
| 426 | ) -> impl IntoResponse { |
| 427 | let mut s = state.inner.lock().unwrap(); |
| 428 | |
| 429 | let key = format!("{db}.{table}"); |
| 430 | if s.no_permission_tables.contains(&key) { |
| 431 | let err = ErrorResponse::new( |
| 432 | Some("table".to_string()), |
| 433 | Some(table.clone()), |
| 434 | Some("No Permission".to_string()), |
| 435 | Some(403), |
| 436 | ); |
| 437 | return (StatusCode::FORBIDDEN, Json(err)).into_response(); |
| 438 | } |
| 439 | |
| 440 | if s.tables.remove(&key).is_some() { |
| 441 | s.no_permission_tables.remove(&key); |
| 442 | (StatusCode::OK, Json(serde_json::json!(""))).into_response() |
| 443 | } else { |
| 444 | let err = ErrorResponse::new( |
| 445 | Some("table".to_string()), |
| 446 | Some(table), |
| 447 | Some("Not Found".to_string()), |
| 448 | Some(404), |
| 449 | ); |
| 450 | (StatusCode::NOT_FOUND, Json(err)).into_response() |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | /// Handle POST /rename-table - rename a table. |
| 455 | pub async fn rename_table( |
no test coverage detected