> make all
mkdir -p bin
go build -o bin/book-store-api-server
❯ bin/book-store-api-server serve --port 8080 main ✱ ◼
serving at port 8080
- POST /authorize
- Implements Basic Auth
❯ curl -X POST --user admin:admin localhost:8080/authorize token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzQ1NTA4ODQsIm5hbWUiOiJhZG1pbiJ9.7eyf8XmnZHgG0CNUQXJqjy4m8cvGITCkdUg2eFJ1CLo
- GET /books
❯ curl -X GET -H "Authorization: Bearer <token>" localhost:8080/books [{"author":"The MANIAC","category":"Novel","id":0,"isbn":"9780593654491","title":"Benjamín Labatut"},{"author":"George Orwell","category":"Dystopian","id":1,"isbn":"9780451524935","title":"1984"},{"author":"J.K. Rowling","category":"Fantasy","id":2,"isbn":"9780439708180","title":"Harry Potter and the Sorcerer's Stone"},{"author":"Yuval Noah Harari","category":"Non-Fiction","id":3,"isbn":"9780062316097","title":"Sapiens: A Brief History of Humankind"},{"author":"Michelle Obama","category":"Biography","id":4,"isbn":"9781524763138","title":"Becoming"}]
- GET /book/{id}
❯ curl -X GET -H "Authorization: Bearer <token> localhost:8080/book/2 {"author":"J.K. Rowling","category":"Fantasy","id":2,"isbn":"9780439708180","title":"Harry Potter and the Sorcerer's Stone"}
- DELETE /book/{id}
❯ curl -X DELETE -H "Authorization: Bearer <token> localhost:8080/book/1 Deleted
- PUT /book/{id}
❯ curl -X PUT -H "Content-Type: application/json" \ -H "Authorization: Bearer <token>" \ -d '{ "author": "J.K. Rowling", "title": "Harry Potter and the Chamber of Secrets", "category": "Fantasy", "isbn": "9780439064873" }'\ http://localhost:8080/book/3 { "author":"","category":"Fantasy","id":3,"isbn":"9780439064873","title":"Harry Potter and the Chamber of Secrets"}
> make clean
rm -rf bin
> make docker-build
> docker run -p 8080:8080 book-store-api-server
serving at port 8080
Default port is 8080 and other default values can be found at .env file.
> docker run -p 8081:8081 book-store-api-server --port 8081
serving at port 8081
❯ docker run -p 8080:8080 --env PASSWORD=admin book-store-api-server
serving at port 8080
❯ docker run -p 8080:8080 -v $(pwd)/.env:/app/.env book-store-api-server
serving at port 8080
> kubectl create ns book-server
> kubectl apply -f k8s/manifests/deployment.yaml -n book-server