{"id":23408545,"url":"https://github.com/shiponcs/golang-rest-api-server","last_synced_at":"2026-04-30T06:32:40.897Z","repository":{"id":268743917,"uuid":"905332370","full_name":"shiponcs/golang-rest-api-server","owner":"shiponcs","description":"A REST API Server written in Golang serves a Book Store","archived":false,"fork":false,"pushed_at":"2025-01-17T12:56:28.000Z","size":24405,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-14T19:51:57.097Z","etag":null,"topics":["cobra-cli","dotenv","go-chi","golang","http","json"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shiponcs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-18T16:00:33.000Z","updated_at":"2025-01-17T12:56:30.000Z","dependencies_parsed_at":"2025-02-14T19:52:01.491Z","dependency_job_id":"164135ea-6745-45e9-a553-ab549b8d9b89","html_url":"https://github.com/shiponcs/golang-rest-api-server","commit_stats":null,"previous_names":["shiponcs/golang-rest-api-server"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shiponcs%2Fgolang-rest-api-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shiponcs%2Fgolang-rest-api-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shiponcs%2Fgolang-rest-api-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shiponcs%2Fgolang-rest-api-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shiponcs","download_url":"https://codeload.github.com/shiponcs/golang-rest-api-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247957088,"owners_count":21024646,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cobra-cli","dotenv","go-chi","golang","http","json"],"created_at":"2024-12-22T15:15:30.557Z","updated_at":"2026-04-30T06:32:35.861Z","avatar_url":"https://github.com/shiponcs.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A REST API Server in Golang\n\n## Dependecies\n- [go](https://github.com/golang)\n- [spf13/cobra](https://github.com/spf13/cobra),\n- [go-chi/chi](https://github.com/go-chi/chi), \n- [golang-jwt/jwt](https://github.com/golang-jwt/jwt)\n\n## Build and Run the project\n```bash\n  \u003e make all\n  mkdir -p bin\n  go build -o bin/book-store-api-server\n```\n\n```bash\n  ❯ bin/book-store-api-server serve --port 8080                                                                                                                                         main ✱ ◼\n  serving at port 8080\n```\n\n\n## API Endpoints\n- POST /authorize\n    - Implements Basic Auth\n  ```bash\n    ❯ curl -X POST --user admin:admin  localhost:8080/authorize\n    token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzQ1NTA4ODQsIm5hbWUiOiJhZG1pbiJ9.7eyf8XmnZHgG0CNUQXJqjy4m8cvGITCkdUg2eFJ1CLo\n    ```  \n- GET /books\n    ```bash\n      ❯ curl -X GET -H \"Authorization: Bearer \u003ctoken\u003e\" localhost:8080/books\n      [{\"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\"}]\n\n   ```\n- GET /book/{id}\n    ```bash\n  ❯ curl -X GET -H \"Authorization: Bearer \u003ctoken\u003e localhost:8080/book/2\n    {\"author\":\"J.K. Rowling\",\"category\":\"Fantasy\",\"id\":2,\"isbn\":\"9780439708180\",\"title\":\"Harry Potter and the Sorcerer's Stone\"}\n   ```\n- DELETE /book/{id}\n    ```bash\n  ❯ curl -X DELETE -H \"Authorization: Bearer \u003ctoken\u003e localhost:8080/book/1\n    Deleted\n   ```\n- PUT /book/{id}\n    ```bash\n    ❯ curl -X PUT -H \"Content-Type: application/json\" \\\n      -H \"Authorization: Bearer \u003ctoken\u003e\" \\\n      -d '{\n      \"author\": \"J.K. Rowling\",\n      \"title\": \"Harry Potter and the Chamber of Secrets\",\n     \"category\": \"Fantasy\",\n     \"isbn\": \"9780439064873\"\n      }'\\\n      http://localhost:8080/book/3\n    { \"author\":\"\",\"category\":\"Fantasy\",\"id\":3,\"isbn\":\"9780439064873\",\"title\":\"Harry Potter and the Chamber of Secrets\"}\n   ```\n## Clean\n```bash\n  \u003e make clean\n  rm -rf bin\n```\n\n## Docker \n### Build Docker Image\n```bash\n\u003e make docker-build\n```\n### Run Docker Image\n#### Run with default options\n```bash\n\u003e docker run -p 8080:8080 book-store-api-server\nserving at port 8080\n```\nDefault port is 8080 and other default values can be found at .env file.\n\n#### Pass Command Line Arg values\n##### Modify the listening port\n```bash\n\u003e docker run -p 8081:8081 book-store-api-server --port 8081\nserving at port 8081\n\n``` \n#### Modify environment values\n##### Modify the password\n```bash\n❯ docker run -p 8080:8080 --env PASSWORD=admin book-store-api-server\nserving at port 8080\n```\n##### Override the .env file\n###### Mount the new .env file\n```bash\n❯ docker run -p 8080:8080 -v $(pwd)/.env:/app/.env book-store-api-server\nserving at port 8080\n```\n\n### Run in Kubernetes\n```bash\n  \u003e kubectl create ns book-server\n  \u003e kubectl apply -f k8s/manifests/deployment.yaml -n book-server\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshiponcs%2Fgolang-rest-api-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshiponcs%2Fgolang-rest-api-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshiponcs%2Fgolang-rest-api-server/lists"}