Added a new api: "/api/supported_versions" to query the server of supported API versions
This commit is contained in:
parent
89b2a2ae51
commit
bb5fb386a7
3 changed files with 18 additions and 1 deletions
14
src/api/api.rs
Normal file
14
src/api/api.rs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
use actix_web::{HttpResponse, get, web};
|
||||||
|
|
||||||
|
use crate::version::info::Version;
|
||||||
|
|
||||||
|
#[get("/supported_versions")]
|
||||||
|
pub async fn versions() -> HttpResponse {
|
||||||
|
let version = Version::get();
|
||||||
|
HttpResponse::Ok().json(&version.supported_api_versions)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn configure(cfg: &mut web::ServiceConfig) {
|
||||||
|
cfg.service(versions);
|
||||||
|
// Register other version 1 handlers here...
|
||||||
|
}
|
|
@ -1,2 +1,3 @@
|
||||||
pub mod server;
|
pub mod server;
|
||||||
mod endpoints_v1;
|
mod endpoints_v1;
|
||||||
|
mod api;
|
|
@ -1,6 +1,7 @@
|
||||||
use actix_web::{HttpServer, web};
|
use actix_web::{HttpServer, web};
|
||||||
|
|
||||||
use crate::api::endpoints_v1;
|
use crate::api::endpoints_v1;
|
||||||
|
use crate::api::api;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub async fn stop_actix_web(server: actix_web::dev::Server) -> std::io::Result<()> {
|
pub async fn stop_actix_web(server: actix_web::dev::Server) -> std::io::Result<()> {
|
||||||
|
@ -17,6 +18,7 @@ pub fn start_actix_web(port: u16) -> std::io::Result<actix_web::dev::Server> {
|
||||||
let logger = actix_web::middleware::Logger::default();
|
let logger = actix_web::middleware::Logger::default();
|
||||||
actix_web::App::new()
|
actix_web::App::new()
|
||||||
.wrap(logger)
|
.wrap(logger)
|
||||||
|
.service(web::scope("/api").configure(api::configure))
|
||||||
.service(web::scope("/v1").configure(endpoints_v1::configure))
|
.service(web::scope("/v1").configure(endpoints_v1::configure))
|
||||||
})
|
})
|
||||||
.bind(("127.0.0.1", port))?
|
.bind(("127.0.0.1", port))?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue