-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rsjudge-rest): 🎉 add deps for rsjudge-rest
- Loading branch information
1 parent
1307417
commit c87d4a8
Showing
4 changed files
with
12 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ rust-version.workspace = true | |
|
||
[dependencies] | ||
axum = "0.7.4" | ||
tokio = { version = "1.36.0", features = ["net"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
pub fn add(left: usize, right: usize) -> usize { | ||
left + right | ||
} | ||
use std::{io, net::SocketAddr}; | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use axum::{routing::get, Router}; | ||
use tokio::net::TcpListener; | ||
|
||
#[test] | ||
fn it_works() { | ||
let result = add(2, 2); | ||
assert_eq!(result, 4); | ||
} | ||
pub async fn serve(addr: SocketAddr) -> io::Result<()> { | ||
let app = Router::new().route("/", get(|| async { "Hello, World!" })); | ||
let listener = TcpListener::bind(addr).await?; | ||
axum::serve(listener, app).await?; | ||
Ok(()) | ||
} |