🎇 support https
This commit is contained in:
parent
bd91acc5d0
commit
944941db10
7
alist.go
7
alist.go
@ -54,7 +54,12 @@ func main() {
|
|||||||
server.InitApiRouter(r)
|
server.InitApiRouter(r)
|
||||||
base := fmt.Sprintf("%s:%d", conf.Conf.Address, conf.Conf.Port)
|
base := fmt.Sprintf("%s:%d", conf.Conf.Address, conf.Conf.Port)
|
||||||
log.Infof("start server @ %s", base)
|
log.Infof("start server @ %s", base)
|
||||||
err := r.Run(base)
|
var err error
|
||||||
|
if conf.Conf.Https {
|
||||||
|
err = r.RunTLS(base, conf.Conf.CertFile, conf.Conf.KeyFile)
|
||||||
|
} else {
|
||||||
|
err = r.Run(base)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("failed to start: %s", err.Error())
|
log.Errorf("failed to start: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,9 @@ type Config struct {
|
|||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
Port int `json:"port"`
|
Port int `json:"port"`
|
||||||
Database Database `json:"database"`
|
Database Database `json:"database"`
|
||||||
|
Https bool `json:"https"`
|
||||||
|
CertFile string `json:"cert_file"`
|
||||||
|
KeyFile string `json:"key_file"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func DefaultConfig() *Config {
|
func DefaultConfig() *Config {
|
||||||
@ -22,11 +25,7 @@ func DefaultConfig() *Config {
|
|||||||
Port: 5244,
|
Port: 5244,
|
||||||
Database: Database{
|
Database: Database{
|
||||||
Type: "sqlite3",
|
Type: "sqlite3",
|
||||||
User: "",
|
|
||||||
Password: "",
|
|
||||||
Host: "",
|
|
||||||
Port: 0,
|
Port: 0,
|
||||||
Name: "",
|
|
||||||
TablePrefix: "x_",
|
TablePrefix: "x_",
|
||||||
DBFile: "data/data.db",
|
DBFile: "data/data.db",
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user