Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vicradon/basic-crud-golang
Golang implementation of the HNGX backend program
https://github.com/vicradon/basic-crud-golang
Last synced: 27 days ago
JSON representation
Golang implementation of the HNGX backend program
- Host: GitHub
- URL: https://github.com/vicradon/basic-crud-golang
- Owner: vicradon
- Created: 2023-09-16T07:53:57.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-17T07:46:11.000Z (over 1 year ago)
- Last Synced: 2024-12-09T18:14:21.064Z (27 days ago)
- Language: Go
- Homepage: https://hngx-task2-go.onrender.com/api
- Size: 7.17 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Person CRUD API
A CRUD API for a person object implemented in Go.
## On Startup
Install goose using the command:
```bash
go install github.com/pressly/goose/v3/cmd/goose@latest
```## Create a Migration
```bash
goose create make_email_unique_and_auto_increment_id sql
```## Run Migrations
```bash
goose sqlite3 ../database.db up
```## Schema
The person object looks like:
```
{
id: int
first_name: string
last_name: string
email: string
}
```## Available Endpoints
| HTTP Method | Endpoint | Description |
|-------------|-------------|-----------------------------|
| GET | `/api` | Get all persons |
| POST | `/api` | Create a person |
| GET | `/api/:id` | Get a person by id |
| PATCH | `/api/:id` | Update a person's details |
| DELETE | `/api/:id` | Delete a person |## Deployment
To deploy the app, you can easily use the provided Docker image. Build the image using the command below:
```bash
docker build -t /personcrudapi .
```Then run the Docker image using the command below:
```bash
docker run -p 5000:8080 /personcrudapi
```