mirror of
https://github.com/kerberos-io/onvif.git
synced 2025-10-07 00:33:37 +08:00
Add API
This commit is contained in:
37
api/api.go
Normal file
37
api/api.go
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"net/http"
|
||||||
|
"github.com/yakovlevdmv/goonvif"
|
||||||
|
"github.com/yakovlevdmv/goonvif/Device"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RunApi () {
|
||||||
|
router := gin.Default()
|
||||||
|
|
||||||
|
device := goonvif.NewDevice()
|
||||||
|
data, err := device.CallMethod("http://192.168.13.12/onvif/device_service", Device.GetCapabilities{Category:"All"})
|
||||||
|
//_=data
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
router.GET("/:dima", func(c *gin.Context) {
|
||||||
|
//name := c.Param("name")
|
||||||
|
c.XML(http.StatusOK, data)
|
||||||
|
})
|
||||||
|
router.Run()
|
||||||
|
}
|
||||||
|
|
||||||
|
func callNecessaryMethod(serviceName, methodName string) {
|
||||||
|
switch serviceName {
|
||||||
|
case "Device", "device":
|
||||||
|
callDeviceMethonds(methodName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func callDeviceMethonds(methodName string) {
|
||||||
|
|
||||||
|
}
|
@@ -4,7 +4,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func SendSoap(endpoint, message string) string {
|
func SendSoap(endpoint, message string) string {
|
||||||
@@ -14,7 +13,7 @@ func SendSoap(endpoint, message string) string {
|
|||||||
|
|
||||||
b, _ := ioutil.ReadAll(resp.Body)
|
b, _ := ioutil.ReadAll(resp.Body)
|
||||||
|
|
||||||
log.Println(string(b))
|
//log.Println(string(b))
|
||||||
|
|
||||||
return string(b)
|
return string(b)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user