db pool and address
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder};
|
||||
use dotenv::dotenv;
|
||||
|
||||
use witl_api::*;
|
||||
#[post("/echo")]
|
||||
async fn echo(req_body: String) -> impl Responder {
|
||||
HttpResponse::Ok().body(req_body)
|
||||
@@ -13,11 +13,12 @@ async fn manual_hello() -> impl Responder {
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
dotenv().ok();
|
||||
let (port, address) = init_address();
|
||||
HttpServer::new(|| {
|
||||
App::new()
|
||||
.service(hello)
|
||||
.service(echo)
|
||||
.route("/hey", web::get().to(manual_hello))
|
||||
.app_data(web::Data::new(init_dbpool()))
|
||||
})
|
||||
.bind(("localhost", 8080))?
|
||||
.run()
|
||||
|
||||
Reference in New Issue
Block a user