mirror of
https://github.com/hybridgroup/gobot.git
synced 2025-04-26 13:48:49 +08:00
SSL support in Api
This commit is contained in:
parent
ed2bdfb510
commit
1719a02370
23
api.go
23
api.go
@ -10,12 +10,14 @@ import (
|
||||
)
|
||||
|
||||
type api struct {
|
||||
master *Master
|
||||
server *martini.ClassicMartini
|
||||
Host string
|
||||
Port string
|
||||
Username string
|
||||
Password string
|
||||
master *Master
|
||||
server *martini.ClassicMartini
|
||||
Host string
|
||||
Port string
|
||||
Username string
|
||||
Password string
|
||||
Cert string
|
||||
Key string
|
||||
}
|
||||
|
||||
type jsonRobot struct {
|
||||
@ -51,7 +53,14 @@ var startApi = func(me *api) {
|
||||
}
|
||||
|
||||
host := me.Host
|
||||
go http.ListenAndServe(host+":"+port, me.server)
|
||||
cert := me.Cert
|
||||
key := me.Key
|
||||
|
||||
if cert != "" && key != "" {
|
||||
go http.ListenAndServeTLS(host+":"+port, cert, key, me.server)
|
||||
} else {
|
||||
go http.ListenAndServe(host+":"+port, me.server)
|
||||
}
|
||||
}
|
||||
|
||||
func (me *api) StartApi() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user