8000 GitHub - chamchi00800/shortUrl: url 단축 서비스
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chamchi00800/shortUrl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DB

MYSQL



input --> ID Generator --> BASE62 --> DB
DB --> BASE62(Decode) --> originalUrl

Post 요청을 사용해서 새로운 URL을 만들수 있습니다.

Path Type Description

url

String

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

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

String

url to change

shortUrl

String

shortened url

_links.self.href

String

link to self

_links.response-url.href

String

response-link

Relation Description

self

self link

response-url

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

code

String

error code

message

String

error message

_links.request-url.href

String

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

request-url

GET /notFound HTTP/1.1
Host: localhost:8080
Path Type Description

code

String

error code

message

String

error message

_links.request-url.href

String

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

request-url

About

url 단축 서비스

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0