A simple short URL generator
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.
Go to file
2018-02-23 18:55:44 +08:00
gradle/wrapper archive 2018-02-23 18:55:44 +08:00
src/main archive 2018-02-23 18:55:44 +08:00
.gitignore archive 2018-02-23 18:55:44 +08:00
build.gradle archive 2018-02-23 18:55:44 +08:00
gradlew archive 2018-02-23 18:55:44 +08:00
gradlew.bat archive 2018-02-23 18:55:44 +08:00
LICENSE archive 2018-02-23 18:55:44 +08:00
README.md archive 2018-02-23 18:55:44 +08: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:

{
    "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.