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("Accept", "application/json")
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
ap := Option().Options
|
ap := Option()
|
||||||
for _, api := range ap.API {
|
for _, api := range ap.API {
|
||||||
req.Header.Set(api.Name, api.Value)
|
req.Header.Set(api.Name, api.Value)
|
||||||
}
|
}
|
||||||
|
23
data.go
23
data.go
@ -4,26 +4,25 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Options main program options
|
|
||||||
type Options struct {
|
type Options struct {
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Site string `json:"site"`
|
Site string `json:"site"`
|
||||||
Options struct {
|
Server struct {
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
Port int `json:"port"`
|
Port int `json:"port"`
|
||||||
Ace struct {
|
} `json:"server"`
|
||||||
DynamicReload bool `json:"DynamicReload"`
|
Ace struct {
|
||||||
BaseDir string `json:"BaseDir"`
|
DynamicReload bool `json:"DynamicReload"`
|
||||||
} `json:"ace"`
|
BaseDir string `json:"BaseDir"`
|
||||||
API []struct {
|
} `json:"ace"`
|
||||||
Name string `json:"name"`
|
API []struct {
|
||||||
Value string `json:"value"`
|
Name string `json:"name"`
|
||||||
} `json:"api"`
|
Value string `json:"value"`
|
||||||
} `json:"options"`
|
} `json:"api"`
|
||||||
Database struct {
|
Database struct {
|
||||||
Server string `json:"server"`
|
Server string `json:"server"`
|
||||||
DB string `json:"db"`
|
Db string `json:"db"`
|
||||||
User string `json:"user"`
|
User string `json:"user"`
|
||||||
Passwd string `json:"passwd"`
|
Passwd string `json:"passwd"`
|
||||||
} `json:"database"`
|
} `json:"database"`
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
func dbConnect() *sql.DB {
|
func dbConnect() *sql.DB {
|
||||||
resp := Option().Database
|
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 {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user