|
5 years ago | |
---|---|---|
gradle/wrapper | 5 years ago | |
src/main | 5 years ago | |
.gitignore | 5 years ago | |
LICENSE | 5 years ago | |
README.md | 5 years ago | |
build.gradle | 5 years ago | |
gradlew | 5 years ago | |
gradlew.bat | 5 years ago |
README.md
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:
{
"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:
{
"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.