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

27 lines
589 B
Rust
Raw Normal View History

2021-03-16 01:11:10 +08:00
use actix_web::get;
2020-12-12 20:32:06 +08:00
use actix_web::web;
use actix_web::HttpResponse;
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 22:54:07 +08:00
async fn list(data: web::Data<Data>) -> HttpResponse {
2021-02-16 22:28:19 +08:00
let api_keys = data.api_keys.clone();
2021-02-26 16:10:04 +08:00
HttpResponse::Ok().json(&KeysResponse {
2021-02-16 22:28:19 +08:00
private: api_keys.private,
public: api_keys.public,
})
2020-12-12 20:32:06 +08:00
}