Skip to content

moritiza/url-shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL Shortener

About

Very simple URL shortener written with golang

How can I run it?

#1 Make sure the docker is installed

docker --version
If the docker is not installed, you can use this link

Install Docker

#2 Make sure the docker service is running

sudo systemctl start docker.service

#3 Execute docker-compose build command

sudo docker-compose build --no-cache

#4 Execute docker-compose up command

sudo docker-compose up --force-recreate

#5 Make sure everything is OK! 😉

curl -X GET "http://localhost:9000/api/ping" -H "Accept: application/json"
Result sample:
{
  "status": true,
  "message": "ok",
  "errors": null,
  "data": "pong"
}

URL section

#1 Create new short url

curl -X POST "http://localhost:9000/api/create-url" -H "Content-Type: application/json" -H "Accept: application/json" -d '{"original_url": "http://google.com"}'
Result sample:
{
  "status": true,
  "message": "created",
  "errors": null,
  "data": {
    "original_url": "http://google.com",
    "short_url": "http://localhost:9000/OZcovl3I"
  }
}

#2 Use from the short url

Open 'short_url' value in the browser and you will be redirected to 'original_url'! 😎

#3 Get short url detail

curl -X GET "http://localhost:9000/api/{url_name}" -H "Accept: application/json"
Result sample:
{
  "status": true,
  "message": "ok",
  "errors": null,
  "data": {
    "original_url": "http://google.com",
    "click": 3
  }
}

How can I test it?

#1 Get into Docker container shell

sudo docker exec -it url_shortener_app bash

#2 Execute artisan command

go clean -testcache
go test ./...

About

Very simple URL shortener written with golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published