createWebSubRequest returns a subscribe/unsubscribe request that implements the WebSub (formerly PubSubHubbub) protocol. See: https://www.w3.org/TR/websub/#subscriber-sends-subscription-request
(ctx context.Context, hubMode, owner, repo, event, callback string, secret []byte)
| 255 | // |
| 256 | // See: https://www.w3.org/TR/websub/#subscriber-sends-subscription-request |
| 257 | func (s *RepositoriesService) createWebSubRequest(ctx context.Context, hubMode, owner, repo, event, callback string, secret []byte) (*http.Request, error) { |
| 258 | topic := fmt.Sprintf( |
| 259 | "https://github.com/%v/%v/events/%v", |
| 260 | owner, |
| 261 | repo, |
| 262 | event, |
| 263 | ) |
| 264 | form := url.Values{} |
| 265 | form.Add("hub.mode", hubMode) |
| 266 | form.Add("hub.topic", topic) |
| 267 | form.Add("hub.callback", callback) |
| 268 | if secret != nil { |
| 269 | form.Add("hub.secret", string(secret)) |
| 270 | } |
| 271 | body := strings.NewReader(form.Encode()) |
| 272 | |
| 273 | req, err := s.client.NewFormRequest(ctx, "hub", body) |
| 274 | if err != nil { |
| 275 | return nil, err |
| 276 | } |
| 277 | |
| 278 | return req, nil |
| 279 | } |
no test coverage detected