Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
go-gitlab
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
go-gitlab
Commits
0e4fc277
Commit
0e4fc277
authored
Dec 02, 2015
by
Gabor Pipicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use json encoded request body for payload of POST and PUT
parent
9ab25f93
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
gitlab.go
gitlab.go
+14
-0
No files found.
gitlab.go
View file @
0e4fc277
...
...
@@ -17,6 +17,7 @@
package
gitlab
import
(
"bytes"
"encoding/json"
"errors"
"fmt"
...
...
@@ -216,6 +217,19 @@ func (c *Client) NewRequest(method, path string, opt interface{}) (*http.Request
Host
:
u
.
Host
,
}
if
method
==
"POST"
||
method
==
"PUT"
{
bodyBytes
,
err
:=
json
.
Marshal
(
opt
)
if
err
!=
nil
{
return
nil
,
err
}
bodyReader
:=
bytes
.
NewReader
(
bodyBytes
)
u
.
RawQuery
=
""
req
.
Body
=
ioutil
.
NopCloser
(
bodyReader
)
req
.
ContentLength
=
int64
(
bodyReader
.
Len
())
req
.
Header
.
Set
(
"Content-Type"
,
"application/json"
)
}
req
.
Header
.
Set
(
"Accept"
,
"application/json"
)
req
.
Header
.
Set
(
"PRIVATE-TOKEN"
,
c
.
token
)
if
c
.
UserAgent
!=
""
{
...
...
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