新增wss与https功能

This commit is contained in:
boyce
2019-03-04 15:13:42 +08:00
parent b4d5a6636e
commit a2d8afda9f
5 changed files with 62 additions and 6 deletions

View File

@@ -33,10 +33,17 @@ type HttpServerService struct {
port uint16
controllerMaps ControllerMapsType
certfile string
keyfile string
ishttps bool
}
func (slf *HttpServerService) OnInit() error {
slf.httpserver.Init(slf.port, slf.initRouterHandler(), 10*time.Second, 10*time.Second)
if slf.ishttps == true {
slf.httpserver.SetHttps(slf.certfile, slf.keyfile)
}
return nil
}
@@ -121,3 +128,15 @@ func (slf *HttpServerService) GetMethod(strCallPath string) (*reflect.Value, err
return &value, nil
}
func (slf *HttpServerService) SetHttps(certfile string, keyfile string) bool {
if certfile == "" || keyfile == "" {
return false
}
slf.ishttps = true
slf.certfile = certfile
slf.keyfile = keyfile
return true
}