Skip to content

Latest commit

 

History

History
63 lines (40 loc) · 1.3 KB

README.md

File metadata and controls

63 lines (40 loc) · 1.3 KB

URL Shortener

this repo can be use in only local environment not serve into the server.

base on this blog -> https://dev.to/mahadevans87/building-a-fast-url-shortener-with-go-and-redis-31b9

Installation

Redis

  • Install redis on machine
brew install redis
  • Starting and stopping Redis using launchd
// start redis
brew services start redis

// stop redis
brew services stop redis
  • more detail other command for redis https://redis.io/docs/getting-started/installation/install-redis-on-mac-os/

Docker for serve Redis and Api Url shortener to container

  • on my machine I usepodman for serve to container

  • install podman and podman compose

brew install podman

brew install podman-compose
  • start podman and compose redis and api to container in your machine
podman machine start

podman ps //check podman machine is started

podman-compose up -d // go to root file this project and run for serve to container

// after finished to run should stop podman
podman-compose down
podman machine stop

Example for use api url shortener

##POST example
curl -v -X POST http://localhost:3000/api/v1 -H "Content-Type: application/json" -d '{"url":"https://www.google.com","short":"","expiry":24}'

##GET example
curl -v http://127.0.0.1:3000/OTv0FdGU8Ng