| Crates.io | rgreeter |
| lib.rs | rgreeter |
| version | 0.1.2 |
| created_at | 2023-02-19 05:50:19.712654+00 |
| updated_at | 2023-02-20 10:23:20.973468+00 |
| description | A simple REST API to greeter a user by name. Typically used for quick demos and checks. |
| homepage | |
| repository | https://github.com/kameshsampath/rust-greeter |
| max_upload_size | |
| id | 788666 |
| size | 68,965 |
A rust-lang demo on building API using axum.
The demo application will be crossed compiled into,
aarch64-unknown-linux-musl)x86_64-unknown-linux-musl)The demo uses cargo-zigbuild as tool for cross compilation.
cargo build
Start the server,
./target/debug/rgreeter
Open a new terminal Start the application to run integration tests,
PORT=8080 cargo run
On another terminal run,
cargo test
Once the server is up you can try the following REST URIs,
curl http://localhost:3000/ returns Hello World!curl http://localhost:3000/greet returns Hello! Anonymous!curl http://localhost:3000/greet?name=Jack returns Hello! Jack!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.