Skip to content

Latest commit

 

History

History
75 lines (58 loc) · 1.23 KB

File metadata and controls

75 lines (58 loc) · 1.23 KB

Rust API

Template For Building Rest APIs With Rust

Rust Actix Web License

Getting Started

git clone https://github.com/stormfiber/rust_api
cd rust_api

Build and Run

cargo build
cargo run

Test Routes

  • Shorten a URL (POST)
curl -X POST http://127.0.0.1:3000/url/shorten \
     -H "Content-Type: application/json" \
     -d '{"url": "https://example.com"}'
  • Response Example:
{
  "short_url": "s19"
}
  • Expand a short URL (GET)
http://127.0.0.1:3000/url/expand?short=s19
  • Response Example:
{
  "url": "https://example.com"
}
  • GET QR as PNG Browser
http://127.0.0.1:3000/qr/generate_png?message=HelloWorld
  • POST QR as Base64 JSON
curl -X POST http://127.0.0.1:3000/qr/generate_base64 \
     -H "Content-Type: application/json" \
     -d '{"message": "HelloWorld"}'
  • Response Example:
{
  "message": "HelloWorld",
  "qr_base64": "iVBORw0KGgoAAAANSUhEUgAA..."
}