implement config file

This commit is contained in:
2019-07-25 14:29:02 +02:00
parent 9ddca46ea7
commit e12876b3ed
7 changed files with 49 additions and 17 deletions

25
config/config.go Normal file
View File

@ -0,0 +1,25 @@
package config
import (
"log"
"github.com/tkanos/gonfig"
)
type Configuration struct {
DB_HOST string
DB_PORT string
DB_USER string
DB_PASSWORD string
DB_NAME string
JWT_SECRET string
}
func GetConfig() Configuration {
configuration := Configuration{}
err := gonfig.GetConf("config/config.json", &configuration)
if err != nil {
log.Fatalf("Failed to load configuration file, error: %v", err)
}
return configuration
}

8
config/config.json Normal file
View File

@ -0,0 +1,8 @@
{
"DB_HOST":"localhost",
"DB_PORT":"5432",
"DB_USER":"graphql",
"DB_PASSWORD":"graphql",
"DB_NAME":"graphql",
"JWT_SECRET":"cadoles"
}