Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
32d43108
Commit
32d43108
authored
Oct 14, 2017
by
astaxie
Committed by
GitHub
Oct 14, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2886 from hurisheng/patch-1
add XMLBody method for httplib
parents
c56704f3
37d4bb3d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletion
+13
-1
httplib.go
httplib/httplib.go
+13
-1
No files found.
httplib/httplib.go
View file @
32d43108
...
...
@@ -317,7 +317,19 @@ func (b *BeegoHTTPRequest) Body(data interface{}) *BeegoHTTPRequest {
}
return
b
}
// XMLBody adds request raw body encoding by XML.
func
(
b
*
BeegoHTTPRequest
)
XMLBody
(
obj
interface
{})
(
*
BeegoHTTPRequest
,
error
)
{
if
b
.
req
.
Body
==
nil
&&
obj
!=
nil
{
byts
,
err
:=
xml
.
Marshal
(
obj
)
if
err
!=
nil
{
return
b
,
err
}
b
.
req
.
Body
=
ioutil
.
NopCloser
(
bytes
.
NewReader
(
byts
))
b
.
req
.
ContentLength
=
int64
(
len
(
byts
))
b
.
req
.
Header
.
Set
(
"Content-Type"
,
"application/xml"
)
}
return
b
,
nil
}
// JSONBody adds request raw body encoding by JSON.
func
(
b
*
BeegoHTTPRequest
)
JSONBody
(
obj
interface
{})
(
*
BeegoHTTPRequest
,
error
)
{
if
b
.
req
.
Body
==
nil
&&
obj
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment