diff --git a/web/Rust/axum/.editorconfig b/web/Rust/axum/.editorconfig new file mode 100644 index 0000000..780d697 --- /dev/null +++ b/web/Rust/axum/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +indent_style = space +end_of_line = lf +trim_trailing_whitespace = true +insert_final_newline = true +indent_size = 4 +charset = utf-8 + +[*.{yml,yaml}] +indent_size = 2 + +[Makefile] +indent_style = tab diff --git a/web/Rust/axum/.env.example b/web/Rust/axum/.env.example new file mode 100644 index 0000000..68cc604 --- /dev/null +++ b/web/Rust/axum/.env.example @@ -0,0 +1 @@ +PHTHONUS_PORT=4000 diff --git a/web/Rust/axum/.gitignore b/web/Rust/axum/.gitignore index 2f7896d..14ee500 100644 --- a/web/Rust/axum/.gitignore +++ b/web/Rust/axum/.gitignore @@ -1 +1,2 @@ target/ +.env diff --git a/web/Rust/axum/Cargo.lock b/web/Rust/axum/Cargo.lock index ec2da51..aaec850 100644 --- a/web/Rust/axum/Cargo.lock +++ b/web/Rust/axum/Cargo.lock @@ -567,7 +567,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] -name = "phthonus-axum" +name = "phthonus" version = "0.1.0" dependencies = [ "anyhow", diff --git a/web/Rust/axum/Cargo.toml b/web/Rust/axum/Cargo.toml index 110e575..0ce985d 100644 --- a/web/Rust/axum/Cargo.toml +++ b/web/Rust/axum/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "phthonus-axum" +name = "phthonus" version = "0.1.0" edition = "2021" diff --git a/web/Rust/axum/Makefile b/web/Rust/axum/Makefile new file mode 100644 index 0000000..2371f9a --- /dev/null +++ b/web/Rust/axum/Makefile @@ -0,0 +1,62 @@ +CARGO = cargo +RUSTC = rustc +CROSS = cross + +all: build + +build: + $(CARGO) build + +release: clean + $(CARGO) build --release + +dev: + PHTHONUS_LOG=debug $(CARGO) watch -x run + +run: + $(CARGO) run + +test: + $(CARGO) test + +clean: + $(CARGO) clean + +clean-release: + rm -rf ./target/release/ + rm -rf ./target/debug/ + +check: + $(CARGO) check + +format: + $(CARGO) fmt + +lint: + $(CARGO) clippy + +fix: + $(CARGO) fix --allow-dirty --all-features && $(CARGO) fmt + +build-linux-musl: clean-release + $(CROSS) build --release --target x86_64-unknown-linux-musl + +build-linux-gnu: clean-release + $(CROSS) build --release --target x86_64-unknown-linux-gnu + +build-windows-gnu: clean-release + $(CROSS) build --release --target x86_64-pc-windows-gnu + +build-freebsd: clean-release + $(CROSS) build --release --target x86_64-unknown-freebsd + +build-loongarch: clean-release + $(CROSS) build --release --target loongarch64-unknown-linux-gnu + +deps: + python -m venv venus \ + && source venus/bin/activate \ + && pip install -r scripts/requirements.txt \ + && python scripts/download-core.py + +.PHONY: all diff --git a/web/Rust/axum/src/main.rs b/web/Rust/axum/src/main.rs index 9c6de44..4f76f6e 100644 --- a/web/Rust/axum/src/main.rs +++ b/web/Rust/axum/src/main.rs @@ -22,7 +22,7 @@ async fn main() -> Result<()> { init_logger(); info!("Hello, world!"); - let port = env::var("VENUS_PORT") + let port = env::var("PHTHONUS_PORT") .map(|port| port.parse::().unwrap_or(DEFAULT_PORT)) .unwrap_or(DEFAULT_PORT); let addr = SocketAddr::from(([0, 0, 0, 0], port));