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
136f6986
Unverified
Commit
136f6986
authored
Dec 27, 2018
by
Carl Bergquist
Committed by
GitHub
Dec 27, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14666 from bergquist/close_body
Closes the body properly on successful webhooks
parents
b798a541
24636da8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
1 deletions
+41
-1
devenv/docker/blocks/alert_webhook_listener/Dockerfile
+7
-0
devenv/docker/blocks/alert_webhook_listener/docker-compose.yaml
+5
-0
devenv/docker/blocks/alert_webhook_listener/main.go
+24
-0
pkg/services/notifications/webhook.go
+5
-1
No files found.
devenv/docker/blocks/alert_webhook_listener/Dockerfile
0 → 100644
View file @
136f6986
FROM
golang:latest
ADD
main.go /
WORKDIR
/
RUN
go build
-o
main
.
EXPOSE
3010
ENTRYPOINT
["/main"]
devenv/docker/blocks/alert_webhook_listener/docker-compose.yaml
0 → 100644
View file @
136f6986
alert_webhook_listener
:
build
:
docker/blocks/alert_webhook_listener
network_mode
:
host
ports
:
-
"
3010:3010"
devenv/docker/blocks/alert_webhook_listener/main.go
0 → 100644
View file @
136f6986
package
main
import
(
"fmt"
"io"
"io/ioutil"
"net/http"
)
func
hello
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
body
,
err
:=
ioutil
.
ReadAll
(
r
.
Body
)
if
err
!=
nil
{
return
}
line
:=
fmt
.
Sprintf
(
"webbhook: -> %s"
,
string
(
body
))
fmt
.
Println
(
line
)
io
.
WriteString
(
w
,
line
)
}
func
main
()
{
http
.
HandleFunc
(
"/"
,
hello
)
http
.
ListenAndServe
(
":3010"
,
nil
)
}
pkg/services/notifications/webhook.go
View file @
136f6986
...
...
@@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
...
...
@@ -69,11 +70,14 @@ func (ns *NotificationService) sendWebRequestSync(ctx context.Context, webhook *
return
err
}
defer
resp
.
Body
.
Close
()
if
resp
.
StatusCode
/
100
==
2
{
// flushing the body enables the transport to reuse the same connection
io
.
Copy
(
ioutil
.
Discard
,
resp
.
Body
)
return
nil
}
defer
resp
.
Body
.
Close
()
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
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