Skip to content

Commit

Permalink
Update the readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidtw committed Sep 3, 2023
1 parent 2a130e9 commit 2bb4626
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,31 @@ or set up to run at an interval.
The below code snippet gets you registered to the webhook and events flowing to you.

```golang
r := webhook.Registration{
Config: webhook.DeliveryConfig{
ReceiverURL: receiverURL,
ContentType: contentType,
},
Events: []string{events},
Duration: webhook.CustomDuration(5 * time.Minute),
}

l, _ := listener.New(&r, "https://example.com",
listener.AuthBearer(os.Getenv("WEBHOOK_BEARER_TOKEN")),
l, err := listener.New("https://example.com",
&webhook.Registration{
Config: webhook.DeliveryConfig{
ReceiverURL: receiverURL,
ContentType: contentType,
},
Events: []string{events},
Duration: webhook.CustomDuration(5 * time.Minute),
},
listener.AcceptSHA1(),
listener.Logger(logger),
listener.Interval(1 * time.Minute),
listener.AcceptedSecrets(sharedSecrets...),

_ = l.Register(sharedSecrets[0])
)
if err != nil {
panic(err)
}

err = l.Register(sharedSecrets[0])
if err != nil {
panic(err)
}
```

Authorization is also pretty simple.
Authorization that the information from the webhook likstener provider is also
pretty simple.

```golang
func (el *eventListener) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit 2bb4626

Please sign in to comment.