3 releases
| 0.1.2 | Feb 20, 2023 |
|---|---|
| 0.1.1 | Feb 19, 2023 |
| 0.1.0 | Feb 19, 2023 |
#1447 in HTTP server
21KB
210 lines
Rust Greeter
A rust-lang demo on building API using axum.
The demo application will be crossed compiled into,
- linux/arm64 (
aarch64-unknown-linux-musl) - linux/amd64 (
x86_64-unknown-linux-musl)
The demo uses cargo-zigbuild as tool for cross compilation.
Pre-requisites
Building Locally
cargo build
Start the server,
./target/debug/rgreeter
Testing
Open a new terminal Start the application to run integration tests,
PORT=8080 cargo run
On another terminal run,
cargo test
Testing Application
Once the server is up you can try the following REST URIs,
- Default
curl http://localhost:3000/returnsHello World! - Greeting:
curl http://localhost:3000/greetreturnsHello! Anonymous! - Greeting a person:
curl http://localhost:3000/greet?name=JackreturnsHello! Jack!
Build and Push Image to Docker Registry
Create a file .env under $PROJECT_HOME,
NOTE: You can copy the file .env.example to
.envand update with your setting
PLUGIN_USERNAME=<container registry username>
PLUGIN_PASSWORD=<container registry password>
PLUGIN_REPO=<container image repo to push image>
PLUGIN_REGISTRY=<container registry to use>
e.g.
PLUGIN_USERNAME=octocat
PLUGIN_PASSWORD=octocat registry password
PLUGIN_REPO=ghcr.io/octocat/rgreeter
PLUGIN_REGISTRY=ghcr.io
task ci
Once the image is pushed run the following command,
docker-compose up
Find the exposed port using the command docker ps and test the application the URIs.
NOTE: If the port
8080is not available on your machine, try using other ports.
Dependencies
~9–15MB
~272K SLoC