changed options format

This commit is contained in:
Michael 2019-07-08 08:59:46 +01:00
parent f29175fb66
commit 07e6748060
3 changed files with 13 additions and 14 deletions

2
api.go
View File

@ -62,7 +62,7 @@ func Request(path string) ([]byte, *logger.HTTPError) {
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
ap := Option().Options
ap := Option()
for _, api := range ap.API {
req.Header.Set(api.Name, api.Value)
}

23
data.go
View File

@ -4,26 +4,25 @@ import (
"time"
)
// Options main program options
type Options struct {
Title string `json:"title"`
Description string `json:"description"`
Site string `json:"site"`
Options struct {
Server struct {
Address string `json:"address"`
Port int `json:"port"`
Ace struct {
DynamicReload bool `json:"DynamicReload"`
BaseDir string `json:"BaseDir"`
} `json:"ace"`
API []struct {
Name string `json:"name"`
Value string `json:"value"`
} `json:"api"`
} `json:"options"`
} `json:"server"`
Ace struct {
DynamicReload bool `json:"DynamicReload"`
BaseDir string `json:"BaseDir"`
} `json:"ace"`
API []struct {
Name string `json:"name"`
Value string `json:"value"`
} `json:"api"`
Database struct {
Server string `json:"server"`
DB string `json:"db"`
Db string `json:"db"`
User string `json:"user"`
Passwd string `json:"passwd"`
} `json:"database"`

View File

@ -8,7 +8,7 @@ import (
func dbConnect() *sql.DB {
resp := Option().Database
db, err := sql.Open("mysql", resp.User+":"+resp.Passwd+"@tcp("+resp.Server+")/"+resp.DB)
db, err := sql.Open("mysql", resp.User+":"+resp.Passwd+"@tcp("+resp.Server+")/"+resp.Db)
if err != nil {
fmt.Println(err)
} else {