This repository has been archived on 2018-02-23. You can view files and clone it, but cannot push or open issues or pull requests.
url-shortener/README.md

84 lines
1.6 KiB
Markdown
Raw Permalink Normal View History

2018-02-23 10:55:44 +00:00
# url-shortener
A simple short URL generator, written in kotlin.
## 1. API
### 1.1 Create new URL
> POST /manage
Create a new short URL. Accepts content-type `application/x-www-form-urlencoded`.
Body should contain one parameter, `url`, the desired URL to be shortened.
Returns `application/json`, format:
```json
{
"err" : 0,
"data" : {
"id" : "<Long>: ID of short URL",
"uuid" : "<String>: 22 character unique string"
}
}
```
This API requires authentication.
### 1.2 Get all URL
> GET /manage
Return a list of all URLs you've created.
Returns `application/json`, format:
```json
{
"err" : 0,
"data" : [
{
"id" : "<Long>: ID of short URL",
"uuid" : "<String>: 22 character unique string",
"url" : "<String>: The exact URL to be redirected to"
},
{
"..." : "..."
},
"..."
]
}
```
This API requires authentication.
### 1.3 Delete URL
> DELETE /manage/{id}
Delete a URL with the given ID.
This API requires authentication.
### 1.4 Using short URL
> GET /{uuid}
If the given UUID is valid, server will return a `302 Found`, and your browser will redirect you to the corresponding real URL.
Otherwise you'll get a `404 Not Found`.
## 2. Authentication
Managing short URLs requires authentication.
Simply specify `x-auth-id` and `x-auth-token` in HTTP header.
You should manually add users in the `auth` table.
## 3. Build
This project provides a Gradle wrapper, so it's easy to build.
Be sure to configure your MySQL database and edit the `application.properties` file before running.