diff --git a/api.go b/api.go index 26d44de3..3a9e6e2e 100644 --- a/api.go +++ b/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() { diff --git a/master.go b/master.go index ec70511d..f7775917 100644 --- a/master.go +++ b/master.go @@ -9,7 +9,7 @@ import ( type Master struct { Robots []*Robot NumCPU int - Api *api + Api *api } func GobotMaster() *Master { @@ -26,7 +26,7 @@ func (m *Master) Start() { runtime.GOMAXPROCS(m.NumCPU) if m.Api != nil { - m.Api.StartApi() + m.Api.StartApi() } for s := range m.Robots {