Skip to content

itsshashank/url-shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

url-shortener

How to use

Create new short url:

curl -X POST http://localhost:8080/short \
  -H 'Content-Type: application/json' \
  -d '{
        "url": "https://github.com"
}'

The response:

{"ShortUrl":"localhost:8080/a3ebZ2l","message":"short url created successfully"}

Get redirected:

 curl -X GET localhost:8080/a3ebZ2l

The response:

<a href="https://github.com">Permanent Redirect</a>.

Get ShortURL info

curl -X GET localhost:8080/a3ebZ2l/info

The response:

{"ShortUrl":"localhost:8080/a3ebZ2l","longUrl":"https://github.com"}

How to Run in Docker

Build Docker from file

docker build -f hack/Dockerfile . -t urlshort

Run locally

docker run -p 8000:8080 urlshort

Can access on localhost:8000 or at containerip:8080

docker inspect 480cf1308d0d | grep "IPAddress"
➜  url-shortener git:(main) ✗ docker inspect c2499030d285 | grep "IPAddress"
            "SecondaryIPAddresses": null,
            "IPAddress": "172.17.0.3",
                    "IPAddress": "172.17.0.3",

Run from Docker hub

➜  url-shortener git:(main) ✗ podman run -p 8000:8080 itsshashank/url-shortener:latest
[GIN] 2022/08/12 - 23:23:40 | 200 |     153.062µs |      10.0.2.100 | GET      "/"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published