Goal of this project is shortening an URL using Go language and its Fiber backend framework:
- Clone the repository with
git clone github.com/kelma01/url_shortener - Make sure that your PC has Go. Type
go versionin terminal to check, if it is not installed, (in Linux) you can typesudo snap install goon terminal to install. - Get the libraries that project needs
- Install PostgreSQL to manage DB relations with
sudo apt install postgresqland create your user in there with the name of database you will use. Start service withsudo systemctl start postgresqlWithpsql -u <username> -d url_shortener, enter the PostgreSQL terminal and\c url_shortenerto use the db. Do not forget to change DB configuration files in code. - Install Redis with
sudo apt install redis-toolsandsudo apt install redis-server. Then start withsudo systemctl start redis-server. After that withredis-cli, the redis terminal can be used. - With
go run cmd/server/main.goyou can run the project in your localhost. Host is served onlocalhost:8080.
#GET REQUEST
curl -X GET http://localhost:8080
#POST REQUEST:
curl --header "Content-Type: application/json" --request POST --data '{"original_url": "https://www.google.com"}' http://localhost:8080
#DELETE REQUEST:
curl -X DELETE http://localhost:8080/shorturlsudo docker-compose down
sudo docker rm -f $(sudo docker ps -aq)
sudo docker volume prune -f
sudo docker network prune -f
sudo docker-compose up --buildsystemctl stop postgresql
systemctl stop redis
minikube start --driver=docker
eval $(minikube -p minikube docker-env)
docker build -t urltest:latest .
kubectl apply -f /k8s
minikube service url-shortener-app