Generate URL with short ID and redirect to the original URL when visited.
Redirects to shortId's original URL.
Parameters
Name | Description | Location | Type | Sample Value |
---|---|---|---|---|
shortId | Short ID to lookup original URL. | Path | String | appwrite |
Response
Sample 302
Response:
Redirects to the original URL.
Location: https://appwrite.io
Sample 404
Response:
When no URL is found for the short ID.
URL not found
Create a new short ID for a URL.
Parameters
Name | Description | Location | Type | Sample Value |
---|---|---|---|---|
Content-Type | Content type | Header | application/json |
|
longUrl | Long URL to shorten | Body | String | https://mywebapp.com/pages/hugelongurl?with=query¶ms=123 |
shortId | Short ID to use | Body | String | discord |
Response
Sample 200
Response:
Returns the short URL and the original URL.
{
"ok": true,
"shortId": "appwrite",
"longUrl": "https://appwrite.io"
}
Sample 400
Response:
When the request body doesn't deserialise properly.
{
"ok": false,
"error": "Missing request body"
}
Setting | Value |
---|---|
Runtime | Go (1.22) |
Entrypoint | main.go |
Permissions | any |
Timeout (Seconds) | 15 |
No environment variables required.