mirror of
https://github.com/thegeeklab/github-releases-notifier.git
synced 2024-11-25 07:40:41 +00:00
Add missing godoc comments and actually use the context for the request
This commit is contained in:
parent
6a5a74ef87
commit
b6a688b1d0
6
slack.go
6
slack.go
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user