-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
33 lines (23 loc) · 993 Bytes
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Simple URL Shortener using Xitrum (https://github.com/xitrum-framework/xitrum) and MongoDB.
URLs will be shorten to a 7-character string using base 62. In theory, it can
support up to 62^7 unique URLs (more than 3 trillions).
== POST
To shorten a URL, send a POST request to:
http://SERVER/api/shorten?url=ESCAPED_URL
Response:
* 200: the body is a random key to lookup the original URL later
* 500: server error, for example the DB may be down
If you do not like the key to be random, send a POST request to:
http://SERVER/api/shorten?url=ESCAPED_URL&key=KEY
Characters in KEY must be a-z, A-Z, _, or -
Response:
* 200 or 500: same as above
* 400: the key contains invalid charater(s)
* 409: the key has been chosen
== GET
To be redirected to the original (non-escaped) URL, send a GET request to:
http://SERVER/KEY
Response:
* 302: the client will be redirected to the original URL
* 404: invalid key or the key has been expired
* 500: server error, for example the DB may be down