mirror of
https://codeberg.org/JasterV/chat-rooms-actix.git
synced 2026-04-27 02:15:42 +00:00
heroku reconfigured
This commit is contained in:
parent
364e506166
commit
8f1d11fb24
3 changed files with 17 additions and 5 deletions
1
Procfile
1
Procfile
|
|
@ -1 +0,0 @@
|
|||
web: ./target/release/actix-messaging
|
||||
5
heroku.yml
Normal file
5
heroku.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
build:
|
||||
docker:
|
||||
web: Dockerfile
|
||||
run:
|
||||
web: ./actix-messaging
|
||||
18
src/main.rs
18
src/main.rs
|
|
@ -6,20 +6,28 @@ mod routes;
|
|||
|
||||
use crate::{actors::chat_server::ChatServer, models::AppState};
|
||||
use actix::Actor;
|
||||
use actix_web::{App, HttpServer};
|
||||
use actix_web::{App, HttpServer, get};
|
||||
use routes::connect;
|
||||
|
||||
#[get("/hi")]
|
||||
async fn hi() -> &'static str {
|
||||
"Hello, World!"
|
||||
}
|
||||
|
||||
fn get_server_addr() -> String {
|
||||
let port = std::env::var("PORT").expect("PORT env variable not found");
|
||||
format!("127.0.0.1:{}", port)
|
||||
}
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
|
||||
let port = std::env::var("PORT").expect("PORT env variable not found");
|
||||
let addr = format!("127.0.0.1:{}", port);
|
||||
|
||||
let addr = get_server_addr();
|
||||
let chat = ChatServer::new().start();
|
||||
HttpServer::new(move || {
|
||||
App::new()
|
||||
.data(AppState { chat: chat.clone() })
|
||||
.service(connect)
|
||||
.service(hi)
|
||||
})
|
||||
.bind(&addr)?
|
||||
.run()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue