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