Skip to content

Commit

Permalink
Add anyhow
Browse files Browse the repository at this point in the history
  • Loading branch information
willcrichton committed Jul 10, 2024
1 parent aaa7d85 commit cee1026
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
anyhow = "1.0.86"
axum = { workspace = true }
serde = { workspace = true }
tokio = { workspace = true }
8 changes: 5 additions & 3 deletions crates/server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use anyhow::Result;
use axum::{
response::Html,
routing::{get, post},
Expand All @@ -21,10 +22,11 @@ async fn chat(Json(mut chat): Json<Chat>) -> Json<Chat> {
}

#[tokio::main]
async fn main() {
async fn main() -> Result<()> {
let app = Router::new()
.route("/", get(root))
.route("/chat", post(chat));
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, app).await.unwrap();
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await?;
axum::serve(listener, app).await?;
Ok(())
}

0 comments on commit cee1026

Please sign in to comment.