Rust

Link Shortener Service in Rust

New

Develop a minimalistic link-shortening microservice using the `axum` framework and its routing system.

⏱️ 5h 0min
📦 4 modules
🎯 Intermediate

What You'll Build

You'll build a personal web assistant that turns long, noisy URLs into short, readable links you can share or say out loud. The service runs on a domain you control, gives you a compact link on demand, and cleanly redirects people to the exact destination without accounts, ads, or tracking.

Powered by axum and tokio, it exposes a tiny HTTP API for creating new short links and following them via /:code. Errors are explained in plain language, and existing links remain stable thanks to an in-memory map and a dedicated code type, with anyhow used for clear, consistent error handling.

Link Shortener Service in Rust cover

Learning Objectives

  • Build a personal URL shortener web service

  • Define clean routes with axum

  • Run async servers using tokio

  • Manage shared state safely with locks

  • Encode and decode Base62 short codes

  • Return redirects and helpful error responses

Prerequisites

  • Basic Rust syntax and ownership

  • Understanding of REST APIs

  • Familiarity with async/await concepts

  • Rust and cargo installed

  • Basic command-line experience

Assembly Steps

1

Configurable HTTP Service

2

Link Codes And State

3

URL Lookup and Registration

4

URL Shortening Service

Technologies

Rust axum Tokio Serde Anyhow Base62 URL HTTP Redirects Router