refactor(router): 改为结构化 web 项目

This commit is contained in:
2024-08-22 10:18:23 +08:00
parent 7047d896f8
commit 9ba49e0742
10 changed files with 214 additions and 225 deletions

30
service/onvif/util.go Normal file
View File

@ -0,0 +1,30 @@
package onvif
import (
"encoding/xml"
"github.com/IOTechSystems/onvif/gosoap"
"io"
"net/http"
)
func readResponse(resp *http.Response) (string, error) {
b, err := io.ReadAll(resp.Body)
if err != nil {
return "", err
}
return string(b), nil
}
func unmarshalResponse(resp *http.Response, target any) error {
b, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
if err = xml.Unmarshal(b, gosoap.NewSOAPEnvelope(target)); err != nil {
return err
}
return nil
}