MYSQL
input --> ID Generator --> BASE62 --> DB
DB --> BASE62(Decode) --> originalUrl
Post
요청을 사용해서 새로운 URL을 만들수 있습니다.
Path | Type | Description |
---|---|---|
|
|
url to change |
$ curl 'http://localhost:8080/' -i -X POST \
-H 'Content-Type: application/json;charset=UTF-8' \
-H 'Accept: application/hal+json' \
-d '{
"url" : "https://www.naver.com"
}'
POST / HTTP/1.1 Content-Type: application/json;charset=UTF-8 Accept: application/hal+json Content-Length: 39 Host: localhost:8080
{ "url" : "https://www.naver.com" }
Name | Description |
---|---|
|
content type header |
HTTP/1.1 201 Created Location: http://localhost:8080/1 Content-Type: application/hal+json Content-Length: 247
{ "shortUrl" : "9e4cfae4", "url" : "https://www.naver.com", "_links" : { "self" : { "href" : "http://localhost:8080" }, "response-url" : { "href" : "http://localhost:8080/9e4cfae4" } } }
Path | Type | Description |
---|---|---|
|
|
url to change |
|
|
shortened url |
|
|
link to self |
|
|
response-link |
Relation | Description |
---|---|
|
self link |
|
redirect original url |
Get
요청을 사용해서 기존 URL로 생성된 새로운 URL을 통해 사이트에 접속할 수 있습니다.
POST / HTTP/1.1 Content-Type: application/json;charset=UTF-8 Accept: application/hal+json Content-Length: 31 Host: localhost:8080
{ "url" : "www.naver.com" }
Path | Type | Description |
---|---|---|
|
|
error code |
|
|
error message |
|
|
return request-url |
HTTP/1.1 400 Bad Request Content-Type: application/hal+json Content-Length: 182
{ "code" : "BAD_URL", "message" : "URL형식을 다시 확인해주세요", "_links" : { "request-url" : { "href" : "http://localhost:8080/" } } }
Relation | Description |
---|---|
|
request-url |
GET /notFound HTTP/1.1
Host: localhost:8080
Path | Type | Description |
---|---|---|
|
|
error code |
|
|
error message |
|
|
return request url |
HTTP/1.1 404 Not Found Content-Type: application/hal+json Content-Length: 180
{ "code" : "URL_NOT_FOUND", "message" : "URL을 찾지 못했습니다.", "_links" : { "request-url" : { "href" : "http://localhost:8080/" } } }
Relation | Description |
---|---|
|
request-url |