31 lines
491 B
Go
31 lines
491 B
Go
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
|
|
}
|