refactor(router): 改为结构化 web 项目
This commit is contained in:
30
service/onvif/util.go
Normal file
30
service/onvif/util.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user