implement config file
This commit is contained in:
25
config/config.go
Normal file
25
config/config.go
Normal 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
8
config/config.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"DB_HOST":"localhost",
|
||||
"DB_PORT":"5432",
|
||||
"DB_USER":"graphql",
|
||||
"DB_PASSWORD":"graphql",
|
||||
"DB_NAME":"graphql",
|
||||
"JWT_SECRET":"cadoles"
|
||||
}
|
Reference in New Issue
Block a user