All checks were successful
Rust Build / Check (push) Successful in 29s
Rust Build / Test Suite (push) Successful in 35s
Rust Build / Rustfmt (push) Successful in 25s
Rust Build / Clippy (push) Successful in 29s
Rust Build / build (push) Successful in 38s
Release Tagging / release (push) Successful in 28s
Rust Build / Check (pull_request) Successful in 38s
Rust Build / Test Suite (pull_request) Successful in 33s
Rust Build / Rustfmt (pull_request) Successful in 25s
Rust Build / Clippy (pull_request) Successful in 31s
Rust Build / build (pull_request) Successful in 38s
Reviewed-on: #3 Co-authored-by: phoenix <kundeng94@gmail.com> Co-committed-by: phoenix <kundeng94@gmail.com>
42 lines
952 B
Rust
42 lines
952 B
Rust
use axum::{
|
|
// Json,
|
|
Router,
|
|
// http::StatusCode,
|
|
routing::get,
|
|
// routing::{get, post},
|
|
};
|
|
// use serde::{Deserialize, Serialize};
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
// initialize tracing
|
|
tracing_subscriber::fmt::init();
|
|
|
|
// build our application with a route
|
|
let app = Router::new()
|
|
// `GET /` goes to `root`
|
|
.route("/", get(root));
|
|
// `POST /users` goes to `create_user`
|
|
// .route("/users", post(create_user));
|
|
|
|
// run our app with hyper, listening globally on port 3000
|
|
let listener = tokio::net::TcpListener::bind(get_full()).await.unwrap();
|
|
axum::serve(listener, app).await.unwrap();
|
|
}
|
|
|
|
fn get_full() -> String {
|
|
get_address() + ":" + &get_port()
|
|
}
|
|
fn get_address() -> String {
|
|
String::from("0.0.0.0")
|
|
}
|
|
|
|
fn get_port() -> String {
|
|
String::from("3000")
|
|
}
|
|
|
|
// basic handler that responds with a static string
|
|
async fn root() -> &'static str {
|
|
"Hello, World!"
|
|
}
|