Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
go-lib-dingtalk
Project
Project
Details
Activity
Releases
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sven
go-lib-dingtalk
Commits
14758092
Commit
14758092
authored
Sep 14, 2020
by
liupei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复http返回失败问题
parent
dd0f643a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
response.go
response.go
+3
-2
No files found.
response.go
View file @
14758092
...
@@ -31,6 +31,7 @@ func NewResponse(httpResponse http.Response, reqErr error) Response {
...
@@ -31,6 +31,7 @@ func NewResponse(httpResponse http.Response, reqErr error) Response {
// init 解析钉钉返回
// init 解析钉钉返回
func
(
res
*
Response
)
init
()
{
func
(
res
*
Response
)
init
()
{
body
,
err
:=
ioutil
.
ReadAll
(
res
.
httpResponse
.
Body
)
body
,
err
:=
ioutil
.
ReadAll
(
res
.
httpResponse
.
Body
)
defer
res
.
httpResponse
.
Body
.
Close
()
if
err
!=
nil
{
if
err
!=
nil
{
res
.
success
=
false
res
.
success
=
false
res
.
httpErr
=
err
.
Error
()
res
.
httpErr
=
err
.
Error
()
...
@@ -38,7 +39,7 @@ func (res *Response) init() {
...
@@ -38,7 +39,7 @@ func (res *Response) init() {
}
}
res
.
httpBody
=
string
(
body
)
res
.
httpBody
=
string
(
body
)
res
.
errCode
=
gjson
.
Get
(
res
.
httpBody
,
"errcode"
)
.
Int
()
res
.
errCode
=
gjson
.
Get
(
res
.
httpBody
,
"errcode"
)
.
Int
()
if
(
res
.
http
Code
>=
200
&&
res
.
http
Code
<
400
)
&&
res
.
errCode
==
0
{
if
(
res
.
http
Response
.
StatusCode
>=
200
&&
res
.
httpResponse
.
Status
Code
<
400
)
&&
res
.
errCode
==
0
{
res
.
success
=
true
res
.
success
=
true
}
else
{
}
else
{
res
.
success
=
false
res
.
success
=
false
...
@@ -53,7 +54,7 @@ func (res *Response) IsSuccess() bool {
...
@@ -53,7 +54,7 @@ func (res *Response) IsSuccess() bool {
// GetHttpCode 返回httpCode
// GetHttpCode 返回httpCode
func
(
res
*
Response
)
GetHttpCode
()
int
{
func
(
res
*
Response
)
GetHttpCode
()
int
{
return
res
.
httpCode
return
res
.
http
Response
.
Status
Code
}
}
// GetBodyData 返回钉钉返回数据
// GetBodyData 返回钉钉返回数据
...
...
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