comparison pkg/soap/soap.go @ 5712:6270951dda28 revive-cleanup

/interface{}/any/
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 20 Feb 2024 22:37:51 +0100
parents 31973f6f5cca
children
comparison
equal deleted inserted replaced
5711:2dd155cc95ec 5712:6270951dda28
37 } 37 }
38 38
39 type SOAPHeader struct { 39 type SOAPHeader struct {
40 XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Header"` 40 XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Header"`
41 41
42 Items []interface{} `xml:",omitempty"` 42 Items []any `xml:",omitempty"`
43 } 43 }
44 44
45 type SOAPBody struct { 45 type SOAPBody struct {
46 XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Body"` 46 XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Body"`
47 47
48 Fault *SOAPFault `xml:",omitempty"` 48 Fault *SOAPFault `xml:",omitempty"`
49 Content interface{} `xml:",omitempty"` 49 Content any `xml:",omitempty"`
50 } 50 }
51 51
52 type SOAPFault struct { 52 type SOAPFault struct {
53 XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault"` 53 XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault"`
54 54
117 117
118 type SOAPClient struct { 118 type SOAPClient struct {
119 url string 119 url string
120 tlsCfg *tls.Config 120 tlsCfg *tls.Config
121 auth Auth 121 auth Auth
122 headers []interface{} 122 headers []any
123 } 123 }
124 124
125 // ********** 125 // **********
126 // Accepted solution from http://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-golang 126 // Accepted solution from http://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-golang
127 // Author: Icza - http://stackoverflow.com/users/1705598/icza 127 // Author: Icza - http://stackoverflow.com/users/1705598/icza
228 tlsCfg: tlsCfg, 228 tlsCfg: tlsCfg,
229 auth: auth, 229 auth: auth,
230 } 230 }
231 } 231 }
232 232
233 func (s *SOAPClient) AddHeader(header interface{}) { 233 func (s *SOAPClient) AddHeader(header any) {
234 s.headers = append(s.headers, header) 234 s.headers = append(s.headers, header)
235 } 235 }
236 236
237 func (s *SOAPClient) CallContext(ctx context.Context, soapAction string, request, response interface{}) error { 237 func (s *SOAPClient) CallContext(ctx context.Context, soapAction string, request, response any) error {
238 return s.Call(soapAction, request, response) 238 return s.Call(soapAction, request, response)
239 } 239 }
240 240
241 func (s *SOAPClient) Call(soapAction string, request, response interface{}) error { 241 func (s *SOAPClient) Call(soapAction string, request, response any) error {
242 envelope := SOAPEnvelope{} 242 envelope := SOAPEnvelope{}
243 243
244 if s.headers != nil && len(s.headers) > 0 { 244 if s.headers != nil && len(s.headers) > 0 {
245 soapHeader := &SOAPHeader{Items: make([]interface{}, len(s.headers))} 245 soapHeader := &SOAPHeader{Items: make([]any, len(s.headers))}
246 copy(soapHeader.Items, s.headers) 246 copy(soapHeader.Items, s.headers)
247 envelope.Header = soapHeader 247 envelope.Header = soapHeader
248 } 248 }
249 249
250 envelope.Body.Content = request 250 envelope.Body.Content = request