Me trying to learn golang by coding a rest api with clean archetecture following the SOLID principles. So far I've refactored and extracted all dependencies and implemented interfaces so that its easy to swap out db (postgres) and routing (gorilla/mux). Then added SQLite as a DB which I (will) use for testing.
- "/" => "Hello world!"
- Serve static page
- Serve some static pages (home, errors)
- Database (postgres in docker)
- GET request (get all)
- GET request (get by id)
- POST request
- Cleaner archetecture
- Tests (service layer)
- Dockerfile
- docker-compose
- Improove README.md
- Add comments to code
- Tests (controller) - in progress
- Alternative DB (SQLITE) - in progress
- PUT request
- PATCH request
- DELETE request
- MOAR Tests!
- Implement swagger
- Add Authorization
Run db and server in docker with docker-compose:
docker-compose up
Testing with curl:
Get all books:
curl localhost:8080/api/books
Get book with id = 1:
curl localhost:8080/api/books/1
Create a book:
curl localhost:8080/api/books -H "application/json" -d '{"title":"<title>","author":"<author>", "year": 2022}' -X POST
Delete a book with id = 1:
curl localhost:8080/api/books/delete/1 -X DELETE