https://github.com/therealpad/golangapigenerator
Golang server with a config file for routes, data models and database system
https://github.com/therealpad/golangapigenerator
api docker docker-compose github-actions golang makefile pipeline
Last synced: about 2 months ago
JSON representation
Golang server with a config file for routes, data models and database system
- Host: GitHub
- URL: https://github.com/therealpad/golangapigenerator
- Owner: TheRealPad
- Created: 2024-05-14T20:51:05.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-08-11T22:25:09.000Z (almost 2 years ago)
- Last Synced: 2024-08-12T19:46:30.832Z (almost 2 years ago)
- Topics: api, docker, docker-compose, github-actions, golang, makefile, pipeline
- Language: Go
- Homepage:
- Size: 68.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README






# Go API from config file
Create a server where you just need a config file, and the program do the rest
## Config
- server name
- api port
- routes (name and HTTP method + describe which part of CRUD it is)
- data models (name, fields and fields type)
## How to run
By default, the API is just a basic API with a logger to get the activity on the software
Default available routes:
```txt
- /health -> GET # display information about start time of the api, number of api calls and data models
- /health/html -> GET # display above information in html syntax
- /health/traffic -> GET # show all api calls
- /health/traffic/html -> GET # display above information in html syntax
```
If you're on Unix-like system, you can use the [Makefile](Makefile) to run the Docker in background
If you can't use the Makefile, you can run:
```bash
docker-compose -f ./config/docker/docker-compose.yml up --build -d
```
If you can't use Docker, you can run:
```bash
go run .
```
## Database
For now the API only handle MongoDB, you can create a cluster and pass an url looking like that:
```
mongodb+srv://username:password@cluster0.k1vyunp.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0
```
This is the tutorial I followed to get the url https://www.mongodb.com/docs/drivers/go/current/quick-start/