DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

ref: 9fe317c376f9090b5f4c7fe41dfc088b7bf9d248 deck-builder/api/src/main.rs -rw-r--r-- 708 bytes
9fe317c3Jonni Liljamo feat(api): init new api 1 year, 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
 * 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, middleware::Logger, App, HttpResponse, HttpServer, Responder};

#[get("/ping")]
async fn ping() -> impl Responder {
    HttpResponse::Ok().body("pong")
}

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

    // timestamp status_code latency remote_ip request_details
    let log_format = "%t | %s | %Dms | %a | \"%r\"";

    HttpServer::new(|| App::new().wrap(Logger::new(log_format)).service(ping))
        .bind(("0.0.0.0", 8080))?
        .run()
        .await
}