changed options format
This commit is contained in:
parent
f29175fb66
commit
07e6748060
2
api.go
2
api.go
@ -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
23
data.go
@ -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"`
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user