A URL shortener service built with Rust and deployed on Kubernetes.
- URL shortening
- Redirect service
- TLS support via cert-manager
- GitOps deployment with Flux
- Static file serving
- Staging: https://staging.codecraft.engineering (uses Let's Encrypt staging certificates)
- Production: https://codecraft.engineering
- Description: Serves the main application page
- Response: HTML content
- Content-Type:
text/html; charset=utf-8
- Description: Redirects to the original URL associated with the shortcode
- Parameters:
code
: The shortcode (e.g., "B5Z")
- Response:
- Success (307): Redirects to the target URL
- Error (404): Returns "URL shortcode not found"
- Example:
GET /B5Z
redirects to https://codecraft.engineering
- Description: Serves static PNG files from the static directory
- Parameters:
*
: The file path relative to the static directory
- Response:
- Success (200): Returns the file content
- Error (404): Returns "File not found"
- Content-Type:
image/png
for successful responses - Example:
GET /static/CodeCraft%20Engineering%20logo.png
- Description: Returns the application version
- Response: Version string
- Content-Type:
text/plain; charset=utf-8
- Description: Health check endpoint for Kubernetes
- Response: "OK" if the service is healthy
- Content-Type:
text/plain; charset=utf-8
All error responses follow a consistent format:
- 404 Not Found: Plain text error message with
text/plain; charset=utf-8
content type - 400 Bad Request: Plain text error message with
text/plain; charset=utf-8
content type
- Directory traversal attempts are blocked
- Static file serving is limited to PNG files
- Static directory listing is disabled
- URL-encoded paths are properly handled and sanitized
The service is built using:
- Axum web framework
- SQLite for URL storage
- Tower for middleware
- Base32 for shortcode generation