https://github.com/pankalog/mustang-rs
A simple, blazing-fast URL shortener made in Rust using Redis and Axum.
https://github.com/pankalog/mustang-rs
axum redis rust shortener tinyurl
Last synced: about 1 month ago
JSON representation
A simple, blazing-fast URL shortener made in Rust using Redis and Axum.
- Host: GitHub
- URL: https://github.com/pankalog/mustang-rs
- Owner: pankalog
- Created: 2024-11-30T20:55:32.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-30T21:46:47.000Z (over 1 year ago)
- Last Synced: 2025-01-30T14:51:22.459Z (over 1 year ago)
- Topics: axum, redis, rust, shortener, tinyurl
- Language: Rust
- Homepage:
- Size: 6.84 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mustang
A simple, blazing-fast URL shortener made in Rust using Redis and Axum.
## Description
Mustang is a URL shortener service that leverages the speed and efficiency of Redis and the Axum web framework. It provides a straightforward API for creating and retrieving shortened URLs.
## Installation
To install and run Mustang, you need to have Rust and Cargo installed. Clone the repository and build the project using Cargo:
```sh
git clone https://github.com/pankalog/mustang-rs
cd mustang-rs
cargo build --release
```
## Usage
Before running the application, ensure you have a Redis server running and set the necessary environment variables:
```sh
export REDIS_CONN_STRING=redis://127.0.0.1:6379/
export BIND_HOST=127.0.0.1
export BIND_PORT=8080
```
Run the application:
```sh
cargo run --release
```
## API Endpoints
### Create a Shortened URL
**`POST /`**
Request Body:
```json
{
"destination_url": "https://example.com"
}
```
Response:
```json
{
"short_id": "abc123",
"full_url": "http://localhost:8080/abc123",
"destination_url": "https://example.com"
}
```
### Retrieve a Shortened URL
**`GET /{shortened_id}`**
Response:
- **307 Temporary Redirect** to the destination URL if found.
- **404 Not Found** if the shortened ID does not exist.
### OpenAPI Documentation
**`GET /openapi.json`**
Returns the OpenAPI documentation for the API in JSON format. You can also find it on the root of the repository.
## Authors
- Panos Kalogeropoulos - [pkal.dev](https://pkal.dev)