DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

682aa5c0e2daf0feeb773788ea8f9fff8309ca73 — Jonni Liljamo 1 year, 9 months ago f4145f3
feat(api): reimpl /api/info
3 files changed, 37 insertions(+), 0 deletions(-)

A api/src/handlers/info.rs
A api/src/handlers/mod.rs
M api/src/main.rs
A api/src/handlers/info.rs => api/src/handlers/info.rs +24 -0
@@ 0,0 1,24 @@
/*
 * This file is part of laurelin/api
 * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
 *
 * Licensed under GPL-3.0-only.
 * See LICENSE for licensing information.
 */

use actix_web::{get, HttpResponse, Responder};
use serde::Serialize;

#[derive(Serialize)]
pub(crate) struct ApiInfo {
    pub info: String,
    pub ver: String,
}

#[get("/api/info")]
pub(crate) async fn info() -> impl Responder {
    HttpResponse::Ok().json(ApiInfo {
        info: "Laurelin API".to_string(),
        ver: "0.0.1".to_string(),
    })
}

A api/src/handlers/mod.rs => api/src/handlers/mod.rs +10 -0
@@ 0,0 1,10 @@
/*
 * This file is part of laurelin/api
 * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
 *
 * Licensed under GPL-3.0-only.
 * See LICENSE for licensing information.
 */

mod info;
pub(crate) use info::*;

M api/src/main.rs => api/src/main.rs +3 -0
@@ 28,6 28,8 @@ fn run_migrations(conn: &mut PgConnection) {
    conn.run_pending_migrations(MIGRATIONS).unwrap();
}

mod handlers;

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    pretty_env_logger::init();


@@ 51,6 53,7 @@ async fn main() -> std::io::Result<()> {
            .app_data(web::Data::new(pg_pool.clone()))
            .wrap(Logger::new(log_format))
            .service(ping)
            .service(handlers::info)
    })
    .bind(("0.0.0.0", 8080))?
    .run()