A gofr based application implementing CRUD operations on MySQL based docker database image.
docker run --name gofr-mysql -e MYSQL_ROOT_PASSWORD='your password' -e MYSQL_DATABASE=cars_db -p 3306:3306 -d mysql:8.0.30
docker exec -it gofr-mysql mysql -uroot -p'your password' cars_db -e "CREATE TABLE cars (id INT AUTO_INCREMENT PRIMARY KEY, car_name VARCHAR(255) NOT NULL,status VARCHAR(255) NOT NULL);"
- Open terminal and run in the project directory.
go run main.go
- Go to http://localhost:8080/welcome to see the welcome page
- Go to http://localhost:8080/get_cars to see information about the cars.
- Go to http://localhost:8080/cars/delete to delete repaired cars.
- Go to http://localhost:8080/cars/{car_id}/{car_status} replacing car_id and car_status with your values to update the database.
- Go to http://localhost:8080/cars/{car_name}/{car_status} to add new cars to the database.
The .env should have DB_PORT=3306 and HTTP_PORT=8080.
Testing done using main_test.go.