generated from alexejk/go-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A bit of refactoring and more documentation
- Loading branch information
Showing
11 changed files
with
179 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package xmlrpc | ||
|
||
import "encoding/xml" | ||
|
||
// Response is the basic parsed object of the XML-RPC response body. | ||
// While it's not convenient to use this object directly - it contains all the information needed to unmarshal into other data-types. | ||
type Response struct { | ||
Params []ResponseParam `xml:"params>param"` | ||
Fault *ResponseFault `xml:"fault,omitempty"` | ||
} | ||
|
||
// NewResponse creates a Response object from XML body. | ||
// It relies on XML Unmarshaler and if it fails - error is returned. | ||
func NewResponse(body []byte) (*Response, error) { | ||
|
||
response := &Response{} | ||
if err := xml.Unmarshal(body, response); err != nil { | ||
return nil, err | ||
} | ||
|
||
return response, nil | ||
} | ||
|
||
type ResponseParam struct { | ||
Value ResponseValue `xml:"value"` | ||
} | ||
|
||
type ResponseValue struct { | ||
Array []*ResponseValue `xml:"array>data>value"` | ||
Struct []*ResponseStructMember `xml:"struct>member"` | ||
String string `xml:"string"` | ||
Int string `xml:"int"` | ||
Int4 string `xml:"i4"` | ||
Double string `xml:"double"` | ||
Boolean string `xml:"boolean"` | ||
DateTime string `xml:"dateTime.iso8601"` | ||
Base64 string `xml:"base64"` | ||
} | ||
|
||
type ResponseStructMember struct { | ||
Name string `xml:"name"` | ||
Value ResponseValue `xml:"value"` | ||
} | ||
|
||
type ResponseFault struct { | ||
Value ResponseValue `xml:"value"` | ||
} |
Oops, something went wrong.