Handle GET /databases/:name - get a specific database.
(
Path(name): Path<String>,
Extension(state): Extension<Arc<RESTServer>>,
)
| 169 | } |
| 170 | /// Handle GET /databases/:name - get a specific database. |
| 171 | pub async fn get_database( |
| 172 | Path(name): Path<String>, |
| 173 | Extension(state): Extension<Arc<RESTServer>>, |
| 174 | ) -> impl IntoResponse { |
| 175 | let s = state.inner.lock().unwrap(); |
| 176 | |
| 177 | if s.no_permission_databases.contains(&name) { |
| 178 | let err = ErrorResponse::new( |
| 179 | Some("database".to_string()), |
| 180 | Some(name.clone()), |
| 181 | Some("No Permission".to_string()), |
| 182 | Some(403), |
| 183 | ); |
| 184 | return (StatusCode::FORBIDDEN, Json(err)).into_response(); |
| 185 | } |
| 186 | |
| 187 | if let Some(response) = s.databases.get(&name) { |
| 188 | (StatusCode::OK, Json(response.clone())).into_response() |
| 189 | } else { |
| 190 | let err = ErrorResponse::new( |
| 191 | Some("database".to_string()), |
| 192 | Some(name.clone()), |
| 193 | Some("Not Found".to_string()), |
| 194 | Some(404), |
| 195 | ); |
| 196 | (StatusCode::NOT_FOUND, Json(err)).into_response() |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | /// Handle POST /databases/:name - alter database configuration. |
| 201 | pub async fn alter_database( |
no test coverage detected