Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
05952688
Commit
05952688
authored
Feb 24, 2017
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tech: avoid using http.DefaultClient
parent
03354bc4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
2 deletions
+29
-2
pkg/components/imguploader/webdavuploader.go
+15
-1
pkg/services/notifications/webhook.go
+14
-1
No files found.
pkg/components/imguploader/webdavuploader.go
View file @
05952688
...
...
@@ -4,9 +4,11 @@ import (
"bytes"
"fmt"
"io/ioutil"
"net"
"net/http"
"net/url"
"path"
"time"
"github.com/grafana/grafana/pkg/util"
)
...
...
@@ -17,6 +19,18 @@ type WebdavUploader struct {
password
string
}
var
netTransport
=
&
http
.
Transport
{
Dial
:
(
&
net
.
Dialer
{
Timeout
:
60
*
time
.
Second
,
})
.
Dial
,
TLSHandshakeTimeout
:
5
*
time
.
Second
,
}
var
netClient
=
&
http
.
Client
{
Timeout
:
time
.
Second
*
60
,
Transport
:
netTransport
,
}
func
(
u
*
WebdavUploader
)
Upload
(
pa
string
)
(
string
,
error
)
{
url
,
_
:=
url
.
Parse
(
u
.
url
)
url
.
Path
=
path
.
Join
(
url
.
Path
,
util
.
GetRandomString
(
20
)
+
".png"
)
...
...
@@ -28,7 +42,7 @@ func (u *WebdavUploader) Upload(pa string) (string, error) {
req
.
SetBasicAuth
(
u
.
username
,
u
.
password
)
}
res
,
err
:=
http
.
Defaul
tClient
.
Do
(
req
)
res
,
err
:=
ne
tClient
.
Do
(
req
)
if
err
!=
nil
{
return
""
,
err
...
...
pkg/services/notifications/webhook.go
View file @
05952688
...
...
@@ -5,7 +5,9 @@ import (
"context"
"fmt"
"io/ioutil"
"net"
"net/http"
"time"
"golang.org/x/net/context/ctxhttp"
...
...
@@ -22,6 +24,17 @@ type Webhook struct {
HttpHeader
map
[
string
]
string
}
var
netTransport
=
&
http
.
Transport
{
Dial
:
(
&
net
.
Dialer
{
Timeout
:
30
*
time
.
Second
,
})
.
Dial
,
TLSHandshakeTimeout
:
5
*
time
.
Second
,
}
var
netClient
=
&
http
.
Client
{
Timeout
:
time
.
Second
*
30
,
Transport
:
netTransport
,
}
var
(
webhookQueue
chan
*
Webhook
webhookLog
log
.
Logger
...
...
@@ -68,7 +81,7 @@ func sendWebRequestSync(ctx context.Context, webhook *Webhook) error {
request
.
Header
.
Set
(
k
,
v
)
}
resp
,
err
:=
ctxhttp
.
Do
(
ctx
,
http
.
Defaul
tClient
,
request
)
resp
,
err
:=
ctxhttp
.
Do
(
ctx
,
ne
tClient
,
request
)
if
err
!=
nil
{
return
err
}
...
...
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