https://github.com/cfryerdev/golang-api-scaffold
https://github.com/cfryerdev/golang-api-scaffold
Last synced: 4 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/cfryerdev/golang-api-scaffold
- Owner: cfryerdev
- Created: 2024-05-07T19:09:23.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-09T18:11:19.000Z (about 2 years ago)
- Last Synced: 2024-05-09T22:50:09.878Z (about 2 years ago)
- Language: Go
- Size: 238 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Zeroslope GoLang Scaffold
This is the zeroslope microservice architecture using GO. Average response times are around ~2ms for api calls that use a database, and non-database api calls ~28μs. Memory footprint seems to be around 9.9mb of ram allocated to the go process when running the most expensive call.
Recently updated to reflect changes in GO 1.22.X.
## Technologies
Here is a list of the technologies used in this project:
* We use GIN for http routing.
* We use GORM for our ORM layer.
* We use PG for postgres database access.
## Endpoints
Here is an overall layout of what endpoints come with this architecture:
| Method | Route | Description |
| ------ | ---------------------- | -------------------------------------------- |
| N/A | /swagger/index.html | Swagger UI |
| GET | /health/ | Health check. |
| POST | /auth/login | Creates a JWT token for access. |
| GET | /sample | Gets a list of records. |
| GET | /sample/:id | Gets a record by id. |
| POST | /sample/ | Creates a record. |
| PUT | /sample/ | Updates a record. |
| DELETE | /sample/:id | Deletes a record. |
## Console app?
I added a console app just to demonstrate package dependencies and ensure we dont bleed http functionality into places they should not be.
## Installing dependencies
```bash
go mod vendor
```
## Running Api locally
```bash
go run main.go
```
Visit: `http://localhost:8080/swagger/index.html`
## Setting up postgres in docker
```bash
docker run --name pgdb -p 5432:5432 -e POSTGRES_PASSWORD=P4ssw0rd -e POSTGRES_DB=zeroslope -d postgres
```