MeiliSearch/meilisearch-http/src/routes/key.rs

27 lines
588 B
Rust
Raw Normal View History

2020-12-12 13:32:06 +01:00
use actix_web::web;
use actix_web::HttpResponse;
use actix_web::get;
use serde::Serialize;
use crate::helpers::Authentication;
use crate::Data;
pub fn services(cfg: &mut web::ServiceConfig) {
cfg.service(list);
}
#[derive(Serialize)]
struct KeysResponse {
private: Option<String>,
public: Option<String>,
}
#[get("/keys", wrap = "Authentication::Admin")]
2021-02-16 15:54:07 +01:00
async fn list(data: web::Data<Data>) -> HttpResponse {
2021-02-16 15:28:19 +01:00
let api_keys = data.api_keys.clone();
HttpResponse::Ok().json(KeysResponse {
private: api_keys.private,
public: api_keys.public,
})
2020-12-12 13:32:06 +01:00
}