| 39 | } |
| 40 | |
| 41 | pub async fn list_models<M: Model>( |
| 42 | state: web::Data<Arc<RwLock<Master<M>>>>, |
| 43 | ) -> HttpResponse { |
| 44 | let master = state.read().await; |
| 45 | let mut models = Vec::new(); |
| 46 | |
| 47 | if master.model.is_some() { |
| 48 | models.push(ModelObject { |
| 49 | id: M::MODEL_NAME.to_string(), |
| 50 | object: "model".to_string(), |
| 51 | owned_by: "cake".to_string(), |
| 52 | }); |
| 53 | } |
| 54 | |
| 55 | let response = ModelsResponse { |
| 56 | object: "list".to_string(), |
| 57 | data: models, |
| 58 | }; |
| 59 | HttpResponse::Ok().json(response) |
| 60 | } |
| 61 | |
| 62 | async fn not_found() -> actix_web::Result<HttpResponse> { |
| 63 | Ok(HttpResponse::NotFound().body("nope")) |