Skip to content

TheRealPad/golangApiGenerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unit test Integration test Deploy

Go Docker MongoDB

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:

- /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 to run the Docker in background

If you can't use the Makefile, you can run:

docker-compose -f ./config/docker/docker-compose.yml up --build -d

If you can't use Docker, you can run:

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/

About

Golang server with a config file for routes, data models and database system

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages