Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yashmeh/golang-restapi
Just for the sake of learning clean architecture with golang.
https://github.com/yashmeh/golang-restapi
golang hacktoberfest rest-api
Last synced: about 11 hours ago
JSON representation
Just for the sake of learning clean architecture with golang.
- Host: GitHub
- URL: https://github.com/yashmeh/golang-restapi
- Owner: YashMeh
- Created: 2020-09-08T14:03:23.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-24T04:09:31.000Z (about 4 years ago)
- Last Synced: 2023-03-02T14:43:34.322Z (over 1 year ago)
- Topics: golang, hacktoberfest, rest-api
- Language: Go
- Homepage:
- Size: 4.02 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## RESTful API using golang
[![Go Report Card](https://www.goreportcard.com/badge/github.com/YashMeh/golang-restAPI)](https://www.goreportcard.com/badge/github.com/YashMeh/golang-restAPI)
This is a very simple REST api, made entirely for the sake of learning coding patterns in golang.Any suggestions are welcome :smiley:### Endpoints
| Method | Endpoint | Description |
| ------ | ------------ | ---------------------------------- |
| GET | /api/books | returns the list of all books |
| GET | /api/book/id | returns the book with the given id |
| POST | /api/books | creates a book |
| PUT | /api/book/id | updates the book with the given id |
| DELETE | /api/book/id | deletes the book with the given id |### Setup
- Create postgres table using `table.sql`
- Setup environment variables in the root directory using
```
export DBHOST=127.0.0.1
export DBPORT=5432
export DBUSER=parzival
export DBPASS=yash123
export DBNAME=foo
```### Running :running:
```
go build -o restapi && ./restapi
```### Testing :rotating_light:
- Start the API using
```
go build -o restapi && ./restapi
```- Run the tests
```
go test
```### Todo
- [x] Include route tests
- [ ] Include integration tests
- [x] Dockerize
- [x] Generate go-report
- [ ] Create CI### References
- [Clean Architecture by Angad Sharma](https://github.com/L04DB4L4NC3R/clean-architecture-sample)
- [Full stack epic part - 1](https://github.com/morris-ribs/musicstore)