mirror of
https://github.com/thegeeklab/github-releases-notifier.git
synced 2024-11-22 08:50:39 +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"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// SlackSender has the hook to send slack notifications.
|
||||||
type SlackSender struct {
|
type SlackSender struct {
|
||||||
Hook string
|
Hook string
|
||||||
}
|
}
|
||||||
@ -20,6 +21,7 @@ type slackPayload struct {
|
|||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send a notification with a formatted message build from the repository.
|
||||||
func (s *SlackSender) Send(repository Repository) error {
|
func (s *SlackSender) Send(repository Repository) error {
|
||||||
payload := slackPayload{
|
payload := slackPayload{
|
||||||
Username: "GitHub Releases",
|
Username: "GitHub Releases",
|
||||||
@ -43,9 +45,9 @@ func (s *SlackSender) Send(repository Repository) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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()
|
defer cancel()
|
||||||
req.WithContext(ctx)
|
|
||||||
|
|
||||||
resp, err := http.DefaultClient.Do(req)
|
resp, err := http.DefaultClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user