update string comparison in callmethod

This commit is contained in:
Eamon
2018-05-16 17:03:28 +08:00
parent 28cfd7c4d4
commit f4182a60d9

View File

@@ -225,19 +225,19 @@ func buildMethodSOAP(msg string) (gosoap.SoapMessage, error) {
//You should use Authenticate method to call authorized requests. //You should use Authenticate method to call authorized requests.
func (dev Device) CallMethod(method interface{}) (*http.Response, error) { func (dev Device) CallMethod(method interface{}) (*http.Response, error) {
pkgPath := strings.Split(reflect.TypeOf(method).PkgPath(), "/") pkgPath := strings.Split(reflect.TypeOf(method).PkgPath(), "/")
pkg := pkgPath[len(pkgPath)-1] pkg := strings.ToLower(pkgPath[len(pkgPath)-1])
var endpoint string var endpoint string
switch pkg { switch pkg {
case "Device": case "device":
endpoint = dev.endpoints["Device"] endpoint = dev.endpoints["Device"]
case "Event": case "event":
endpoint = dev.endpoints["Event"] endpoint = dev.endpoints["Event"]
case "Imaging": case "imaging":
endpoint = dev.endpoints["Imaging"] endpoint = dev.endpoints["Imaging"]
case "Media": case "media":
endpoint = dev.endpoints["Media"] endpoint = dev.endpoints["Media"]
case "PTZ": case "ptz":
endpoint = dev.endpoints["PTZ"] endpoint = dev.endpoints["PTZ"]
} }