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

https://github.com/cfryerdev/golang-api-scaffold


https://github.com/cfryerdev/golang-api-scaffold

Last synced: 4 days ago
JSON representation

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
```