Skip to content

Commit

Permalink
feat(rsjudge-rest): 🎉 add deps for rsjudge-rest
Browse files Browse the repository at this point in the history
  • Loading branch information
Jisu-Woniu committed Mar 7, 2024
1 parent 1307417 commit c87d4a8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"deps",
"config",
"xtask",
"actions"
"actions",
"rsjudge-rest"
],
"editor.defaultFormatter": "dprint.dprint",
"[dockerfile]": {
Expand Down
1 change: 1 addition & 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/rsjudge-rest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ rust-version.workspace = true

[dependencies]
axum = "0.7.4"
tokio = { version = "1.36.0", features = ["net"] }
19 changes: 8 additions & 11 deletions crates/rsjudge-rest/src/lib.rs
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(())
}

0 comments on commit c87d4a8

Please sign in to comment.