Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
K
koko
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
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
ops
koko
Commits
e922cceb
Commit
e922cceb
authored
Apr 23, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改client
parent
c9ebf9bd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
client.go
pkg/common/client.go
+10
-0
No files found.
pkg/common/client.go
View file @
e922cceb
...
...
@@ -22,6 +22,7 @@ type Client struct {
Timeout
time
.
Duration
Headers
map
[
string
]
string
Auth
ClientAuth
basicAuth
[]
string
cookie
map
[
string
]
string
http
*
http
.
Client
UrlParsers
[]
UrlParser
...
...
@@ -47,6 +48,11 @@ func (c *Client) SetCookie(k, v string) {
c
.
cookie
[
k
]
=
v
}
func
(
c
*
Client
)
SetBasicAuth
(
username
,
password
string
)
{
c
.
basicAuth
=
append
(
c
.
basicAuth
,
username
)
c
.
basicAuth
=
append
(
c
.
basicAuth
,
password
)
}
func
(
c
*
Client
)
SetAuth
(
auth
ClientAuth
)
{
c
.
Auth
=
auth
}
...
...
@@ -86,6 +92,10 @@ func (c *Client) SetAuthHeader(r *http.Request, params ...map[string]string) {
}
r
.
Header
.
Add
(
"Cookie"
,
strings
.
Join
(
cookie
,
";"
))
}
if
len
(
c
.
basicAuth
)
==
2
{
r
.
SetBasicAuth
(
c
.
basicAuth
[
0
],
c
.
basicAuth
[
1
])
return
}
if
c
.
Auth
!=
nil
{
r
.
Header
.
Set
(
"Authorization"
,
c
.
Auth
.
Sign
())
}
...
...
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