Skip to content

Just practicing the implementation of various languages.

Notifications You must be signed in to change notification settings

justintien/url-shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

url-shortener

URL Shortener with mysql support.

Just practicing the implementation of various languages.

  • go
  • java
  • nodejs

Usage

  • up server

    ./build.java.sh # build java first
    # up server
    docker-compose up --build -d

Api

Only the ports are different.

  • go: 3001
  • java: 3002
  • nodejs: 3003

test server alive

curl -X GET http://localhost:3001
# response: server alive!

縮網址

POST /shorten

参数

Attribute Type Required Description
url url yes 要縮短的原網址

example:

curl -X POST \
-H "Content-Type:application/json" \
-d "{\"url\": \"http://www.google.com\"}" \
http://localhost:3001/shorten
response
200 OK
{
    "id": 1,
    "url": "http://www.google.com",
    "shortId": "k3mau1pvbILo",
    "createdAt": "2019-10-23T10:15:28.000+0000",
    "updatedAt": "2019-12-31T10:15:28.000+0000",
    "deletedAt": null
}

or

400 Bad Request
{
    "error": "Invalid url"
}

redirect 縮網址

GET /{shortId}

参数

Attribute Type Required Description
{shortId} String yes 縮網址ID

example:

curl -X GET \
http://localhost:3001/k3mau1pvbILo
response
303 See Other
redirect to: http://www.google.com

or

404 Not Found
{
    "error": "Not Found"
}

About

Just practicing the implementation of various languages.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published