add GET method for shortening
This commit is contained in:
@@ -124,8 +124,8 @@ Health check endpoint.
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/shorten`
|
||||
Create a new short URL. No API key required.
|
||||
### `POST / GET /api/shorten`
|
||||
Create a new short URL (supports both `POST` and `GET`). No API key required.
|
||||
|
||||
Fields can be passed as **query parameters** (URL-encoded) or in a **JSON request body**.
|
||||
Query parameters take precedence over body fields.
|
||||
@@ -217,14 +217,17 @@ Increments `visit_count` on each hit.
|
||||
## Example with `curl`
|
||||
|
||||
```bash
|
||||
# Shorten a URL (JSON body)
|
||||
# Shorten a URL (POST with JSON body)
|
||||
curl -X POST http://localhost:8080/s/api/shorten \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"url": "https://github.com"}'
|
||||
|
||||
# Shorten a URL (query parameters)
|
||||
# Shorten a URL (POST with query parameters)
|
||||
curl -X POST "http://localhost:8080/s/api/shorten?url=https%3A%2F%2Fgithub.com&retention_days=30"
|
||||
|
||||
# Shorten a URL (GET with query parameters)
|
||||
curl "http://localhost:8080/s/api/shorten?url=https%3A%2F%2Fgithub.com"
|
||||
|
||||
# Follow the redirect
|
||||
curl -L http://localhost:8080/s/aB3xYz
|
||||
|
||||
|
||||
Reference in New Issue
Block a user