Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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"}'
```