https://github.com/peeeuzin/url-shortener
A simple URL shortener using Rocket and Diesel.
https://github.com/peeeuzin/url-shortener
diesel nginx postgresql rocket-rs rust
Last synced: 3 months ago
JSON representation
A simple URL shortener using Rocket and Diesel.
- Host: GitHub
- URL: https://github.com/peeeuzin/url-shortener
- Owner: peeeuzin
- License: mit
- Created: 2024-03-05T20:42:59.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-10T15:17:13.000Z (about 1 year ago)
- Last Synced: 2024-03-10T16:27:13.645Z (about 1 year ago)
- Topics: diesel, nginx, postgresql, rocket-rs, rust
- Language: Rust
- Homepage:
- Size: 25.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# URL Shortener
A simple URL shortener using Rocket and Diesel.# Setup
1. Install Docker and Docker compose2. Clone the repository
```bash
git clone https://github.com/peeeuzin/url-shortener
```1. Create a `.env.local` file in the root of the project. See [.env.example](./.env.example) to see the required environment variables.
2. Run the application
```bash
docker compose -f docker-compose.dev.yml up
```to run the application in production mode, use the following command
```bash
docker compose up
```5. Access the application
The application will be available at `http://localhost:3000`# API Documentation
## Create a short URL
**POST /{short_url}**### Body
```json
{
"long_url": "https://example.com"
}
```Where `{short_url}` is the short version of the URL.
## Response
### 200 Ok
```json
{
"short_url": "{short_url}",
"long_url": "https://example.com"}
```### 500 Internal Server Error
```json
{
"error": "Internal Server Error"
}
```## Redirect to the long URL
**GET /{short_url}**Where `{short_url}` is the short version of the URL.
## Response
### 301 Moved Permanently
Redirects to the long URL### 404 Not Found
```json
{
"error": "URL not found"
}
```