0
0
mirror of https://github.com/thegeeklab/github-releases-notifier.git synced 2024-11-13 21:50:39 +00:00

Add missing godoc comments and actually use the context for the request

This commit is contained in:
Matthias Loibl 2017-08-08 12:28:04 +02:00
parent 6a5a74ef87
commit b6a688b1d0
No known key found for this signature in database
GPG Key ID: B1C7DF661ABB2C1A

View File

@ -10,6 +10,7 @@ import (
"time"
)
// SlackSender has the hook to send slack notifications.
type SlackSender struct {
Hook string
}
@ -20,6 +21,7 @@ type slackPayload struct {
Text string `json:"text"`
}
// Send a notification with a formatted message build from the repository.
func (s *SlackSender) Send(repository Repository) error {
payload := slackPayload{
Username: "GitHub Releases",
@ -43,9 +45,9 @@ func (s *SlackSender) Send(repository Repository) error {
if err != nil {
return err
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Millisecond)
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
req = req.WithContext(ctx)
defer cancel()
req.WithContext(ctx)
resp, err := http.DefaultClient.Do(req)
if err != nil {