Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bwhtdev/go-postgres-api
Basic GO REST API with PostgresSQL
https://github.com/bwhtdev/go-postgres-api
Last synced: about 1 month ago
JSON representation
Basic GO REST API with PostgresSQL
- Host: GitHub
- URL: https://github.com/bwhtdev/go-postgres-api
- Owner: bwhtdev
- Created: 2023-08-23T21:25:25.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-08-24T21:59:51.000Z (over 1 year ago)
- Last Synced: 2024-10-30T01:03:58.603Z (about 2 months ago)
- Language: Go
- Size: 42 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-postgres-api
###### To build GO app
- `go mod init ***MOD_NAME***`[NOTE: Sometimes the version of gofiber will cause trouble]
###### To deploy to railway
- `railway init`
- Add a Postgres DB service to app and copy env vars to .env file:
```
railway add
```
(Only allows MySQL, Redis, and MongoDB)
- `railway run go run app.go`
- `railway link`
- `railway up`
- `railway domain`To Test
To fetch data:
```
curl https://go-postgres-api-production.up.railway.app/allbooks
```
To write data:
```
curl https://go-postgres-api-production.up.railway.app/addbook \
--include \
--header "Content-Type: application/json" \
--request "POST" \
--data '{"Title": "First", "Author": "Brad"}'
```