AllowedOrigins []strings option in the configuration file for the API

The App{} struct have been updated to parse a new argument for the API configuration file.

AllowedOrigins permit the user to set what URLs are allowed to send request to the API via CORS headers.
This commit is contained in:
Mael GRAMAIN 2021-01-17 18:12:29 -04:00
parent 3aa2cd4984
commit 8744a7e5df

View file

@ -2,10 +2,11 @@ package utils
//App : Struct for App (dns server) configuration in the config.ini file //App : Struct for App (dns server) configuration in the config.ini file
type App struct { type App struct {
Port int Port int
IP string `ini:"IP"` IP string `ini:"IP"`
Logdir string Logdir string
Logfile bool Logfile bool
AllowedOrigins []string //API conf only
} }
//Database : Struct for SQL Database configuration in the config.ini file //Database : Struct for SQL Database configuration in the config.ini file
@ -29,8 +30,8 @@ type Redis struct {
//DNS : Struct for XFR and NS //DNS : Struct for XFR and NS
type DNS struct { type DNS struct {
XfrIPs []string XfrIPs []string //DNS conf only
Nameservers []string Nameservers []string //API conf only
} }
//Conf : Struct for the whole config.ini file when it will be parsed by go-ini //Conf : Struct for the whole config.ini file when it will be parsed by go-ini
@ -38,6 +39,6 @@ type Conf struct {
AppMode string `ini:"app_mode"` AppMode string `ini:"app_mode"`
App App
Database Database
Redis Redis //DNS conf only
DNS DNS DNS DNS
} }