]> git.cworth.org Git - rust-learning/commit
Add dependencies on axum and tokio and implement a do-nothing server
authorCarl Worth <cworth@cworth.org>
Tue, 10 Mar 2026 05:20:10 +0000 (22:20 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 12 Mar 2026 04:14:58 +0000 (21:14 -0700)
commit74714d369f58c7df9a6fb376ea0f7d82a7b0b5b0
tree3ec69dc3341c8425b428a7a534e516a25c91b936
parent1bc098d3437a50dc0b2570e05aa7dc8653469a08
Add dependencies on axum and tokio and implement a do-nothing server

This server binds to port 3000 on all interfaces and then just listens,
(with no routes configured to do anything).

The axum library gives us the server and router, (which, like I said,
we aren't using yet). And tokio gives us some network functionality
(see the TCP listener and the bind function) as well as some
asynchronous functionality, (see the #[tokio::main] attribute which
saves bunch of boilerplate that would otherwise be needed (creating a
tokio::runtime::Builder and giving it a function to run), and instead
lets us just use the entire body of main as the async function body
that tokio launches.
Cargo.toml
src/main.rs