https://github.com/root27/go-postgres
Go server with Fiber and PostgreSQL
https://github.com/root27/go-postgres
Last synced: over 1 year ago
JSON representation
Go server with Fiber and PostgreSQL
- Host: GitHub
- URL: https://github.com/root27/go-postgres
- Owner: root27
- Created: 2024-02-15T12:39:53.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-02-23T12:26:58.000Z (over 2 years ago)
- Last Synced: 2025-01-10T08:58:36.587Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go server with PostgreSQL
This is a simple Go server with Fiber and PostgreSQL database.
## Running the server
```bash
go run .
```
## Running the PostgreSQL database
```bash
docker run --name postgres -e POSTGRES_USER=test -e POSTGRES_PASSWORD=123 -p 5432:5432 -d postgres
```
### API
#### Create a user
```bash
curl -X POST -H "Content-Type: application/json" -d '{"name":"John Doe", "age": 12}' http://localhost:3000/create
```
#### Get all users
```bash
curl -X GET http://localhost:3000/getAll
```
#### Get user by id
```bash
curl -X GET http://localhost:3000/get/:id
```
#### Update user by id
```bash
curl -X POST -H "Content-Type: application/json" -d '{"name":"John Doe", "age": 12}' http://localhost:3000/update/:id
```
#### Delete user by id
```bash
curl -X DELETE http://localhost:3000/delete/:id
```