Skip to content

Commit eaeb31f

Browse files
committed
wip
2 parents 6febcd6 + 7fc479e commit eaeb31f

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

README.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
[![Quality Score](https://img.shields.io/scrutinizer/g/spatie/laravel-webhook-server.svg?style=flat-square)](https://scrutinizer-ci.com/g/spatie/laravel-webhook-server)
66
[![Total Downloads](https://img.shields.io/packagist/dt/spatie/laravel-webhook-server.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-webhook-server)
77

8-
A webhook is a way for an app to provide information to another app about a certain event. The way the two apps communicate is with a simple HTTP request.
8+
A webhook is a way for an app to provide information to another app about a particular event. The way the two apps communicate is with a simple HTTP request.
99

10-
This package allows you to easily configure and send webhooks in a Laravel app. It has support for [signing calls](https://github.com/spatie/laravel-webhook-server#how-signing-requests-works), [retrying calls and backoff strategies](https://github.com/spatie/laravel-webhook-server#retrying-failed-webhooks).
10+
This package allows you to configure and send webhooks in a Laravel app easily. It has support for [signing calls](https://github.com/spatie/laravel-webhook-server#how-signing-requests-works), [retrying calls and backoff strategies](https://github.com/spatie/laravel-webhook-server#retrying-failed-webhooks).
1111

1212
If you need to receive and process webhooks take a look at our [laravel-webhook-client](https://github.com/spatie/laravel-webhook-client) package.
1313

@@ -80,7 +80,7 @@ return [
8080
];
8181
```
8282

83-
By default the package uses queues to retry failed webhook requests. Be sure to setup a real queue other than `sync` in non-local environments.
83+
By default, the package uses queues to retry failed webhook requests. Be sure to set up a real queue other than `sync` in non-local environments.
8484

8585
## Usage
8686

@@ -90,19 +90,19 @@ This is the simplest way to call a webhook:
9090
WebhookCall::create()
9191
->url('https://other-app.com/webhooks')
9292
->payload(['key' => 'value'])
93-
->signUsingSecret('sign-using-this-secret')
93+
->useSecret('sign-using-this-secret')
9494
->dispatch();
9595
```
9696

97-
This will send a post request to `https://other-app.com/webhooks`. The body of the request will be json encoded version of the array passed to `payload`. The request will have a header called `Signature` that will contain a signature the receiving app can use [to verify](https://github.com/spatie/laravel-webhook-server#how-signing-requests-works) the payload hasn't been tampered with.
97+
This will send a post request to `https://other-app.com/webhooks`. The body of the request will be JSON encoded version of the array passed to `payload`. The request will have a header called `Signature` that will contain a signature the receiving app can use [to verify](https://github.com/spatie/laravel-webhook-server#how-signing-requests-works) the payload hasn't been tampered with.
9898

99-
If the receiving app doesn't respond with a response code starting with `2`, the package will retry calling the webhook after 10 seconds. If that second attempt fails, the package will attempt to call the webhook a final time after 100 seconds. Should that attempt fail the `FinalWebhookCallFailedEvent` will be raised.
99+
If the receiving app doesn't respond with a response code starting with `2`, the package will retry calling the webhook after 10 seconds. If that second attempt fails, the package will attempt to call the webhook a final time after 100 seconds. Should that attempt fail, the `FinalWebhookCallFailedEvent` will be raised.
100100

101101
### How signing requests works
102102

103-
When setting up it's common to generate, store and share a secret secret between your app and the app that wants to receive webhooks. Generating the secret could be done with `Illuminate\Support\Str::random()`, but it's really entirely up to you. The package will use the secret to sign a webhook call.
103+
When setting up, it's common to generate, store, and share a secret between your app and the app that wants to receive webhooks. Generating the secret could be done with `Illuminate\Support\Str::random()`, but it's entirely up to you. The package will use the secret to sign a webhook call.
104104

105-
By default the package will add a header called `Signature` that will contain a signature the receiving app can use the payload hasn't been tampered with. This is how that signature is calculated.
105+
By default, the package will add a header called `Signature` that will contain a signature the receiving app can use the payload hasn't been tampered with. This is how that signature is calculated:
106106

107107
```php
108108
// payload is the array passed to the `payload` method of the webhook
@@ -115,7 +115,7 @@ $signature = hash_hmac('sha256', $payloadJson, $secret);
115115

116116
### Customizing signing requests
117117

118-
If you want to customize the signing process you can create your own custom signer. A signer is any class that implements `Spatie\WebhookServer\Signer`.
118+
If you want to customize the signing process, you can create your own custom signer. A signer is any class that implements `Spatie\WebhookServer\Signer`.
119119

120120
This is what that interface looks like.
121121

@@ -130,9 +130,9 @@ interface Signer
130130
}
131131
```
132132

133-
After creating your signer you can specify it's class name in the `signer` key of the `webhook-server` config file. Your signer will than be used by default in all webhook calls.
133+
After creating your signer, you can specify it's class name in the `signer` key of the `webhook-server` config file. Your signer will then be used by default in all webhook calls.
134134

135-
You can also specify a signer for a specific webhook call
135+
You can also specify a signer for a specific webhook call:
136136

137137
```php
138138
WebhookCall::create()
@@ -141,13 +141,13 @@ WebhookCall::create()
141141
->dispatch();
142142
```
143143

144-
If you just want to customize the name of the header you don't need to use a custom signer, but you can just change the value in the `signature_header_name` in the `webhook-server` config file.
144+
If you want to customize the name of the header, you don't need to use a custom signer, but you can change the value in the `signature_header_name` in the `webhook-server` config file.
145145

146146
### Retrying failed webhooks
147147

148148
When the app to which we're sending the webhook fails to send a response with a `2xx` status code the package will consider the call as failed. The call will also be considered failed if the remote app doesn't respond within 3 seconds.
149149

150-
You can configure that default timeout in the `timeout_in_seconds` key of the `webhook-server` config file. Alternatively you can override the timeout for a specific webhook like this:
150+
You can configure that default timeout in the `timeout_in_seconds` key of the `webhook-server` config file. Alternatively, you can override the timeout for a specific webhook like this:
151151

152152
```php
153153
WebhookCall::create()
@@ -156,7 +156,7 @@ WebhookCall::create()
156156
->dispatch();
157157
```
158158

159-
When a webhook call fails we'll retry the call two more times. You can set the default amount of times we just retry the webhook call in the `tries` key of the config file. Alternatively, you can specify the amount of tries for a specific webhook like this:
159+
When a webhook call fails, we'll retry the call two more times. You can set the default amount of times we retry the webhook call in the `tries` key of the config file. Alternatively, you can specify the number of tries for a specific webhook like this:
160160

161161
```php
162162
WebhookCall::create()
@@ -165,7 +165,7 @@ WebhookCall::create()
165165
->dispatch();
166166
```
167167

168-
To not hammer the remote app we'll wait some time between each attempts. By default we wait 10 seconds between the first and second attempt, 100 seconds between the third and the fourth, 1000 between the fourth and the fifth and so on. The maximum amount of seconds that we'll wait is 100 000, which is about 27 hours. This behaviour is implemented in the default `ExponentialBackoffStrategy`.
168+
To not hammer the remote app we'll wait some time between each attempt. By default, we wait 10 seconds between the first and second attempt, 100 seconds between the third and the fourth, 1000 between the fourth and the fifth and so on. The maximum amount of seconds that we'll wait is 100 000, which is about 27 hours. This behavior is implemented in the default `ExponentialBackoffStrategy`.
169169

170170
You can define your own backoff strategy by creating a class that implements `Spatie\WebhookServer\BackoffStrategy\BackoffStrategy`. This is what that interface looks like:
171171

@@ -178,7 +178,7 @@ interface BackoffStrategy
178178
}
179179
```
180180

181-
You can make your custom strategy the default strategy by specifying it's fully qualified classname in the `backoff_strategy` of the `webhook-server` config file. Alternatively you can specify a strategy for a specific webhook like this.
181+
You can make your custom strategy the default strategy by specifying it's fully qualified class name in the `backoff_strategy` of the `webhook-server` config file. Alternatively, you can specify a strategy for a specific webhook like this.
182182

183183
```php
184184
WebhookCall::create()
@@ -187,14 +187,14 @@ WebhookCall::create()
187187
->dispatch();
188188
```
189189

190-
Under the hood the retrying of the webhook calls is implemented using [delayed dispatching](https://laravel.com/docs/master/queues#delayed-dispatching). Amazon SQS only has support for a small maximum delay. If you're using Amazon SQS for your queues, make sure you do not configure the package in away so there is more than 15 minutes between each attempt.
190+
Under the hood, the retrying of the webhook calls is implemented using [delayed dispatching](https://laravel.com/docs/master/queues#delayed-dispatching). Amazon SQS only has support for a small maximum delay. If you're using Amazon SQS for your queues, make sure you do not configure the package in a way so there are more than 15 minutes between each attempt.
191191

192192

193-
### Customizing the http verb
193+
### Customizing the HTTP verb
194194

195-
By default all webhooks will use the `post` method. You can customize that by specify the http verb you want in the `http_verb` key of the `webhook-server` config file.
195+
By default, all webhooks will use the `post` method. You can customize that by specifying the HTTP verb you want in the `http_verb` key of the `webhook-server` config file.
196196

197-
You can also override the default for a specific call by use the `useHttpVerb` method.
197+
You can also override the default for a specific call by using the `useHttpVerb` method.
198198

199199
```php
200200
WebhookCall::create()
@@ -205,7 +205,7 @@ WebhookCall::create()
205205

206206
### Adding extra headers
207207

208-
You can extra headers by adding the to the `headers` key in the `webhook-server` config file. If you want to add extra headers for a specific webhook you can use the `withHeaders` call.
208+
You can use extra headers by adding them to the `headers` key in the `webhook-server` config file. If you want to add additional headers for a specific webhook, you can use the `withHeaders` call.
209209

210210
```php
211211
WebhookCall::create()
@@ -218,7 +218,7 @@ WebhookCall::create()
218218

219219
### Verifying the SSL certificate of the receiving app
220220

221-
When using an url that starts with `https://` the package will verify if the SSL certificate of the receiving party is valid. If it is not, we will consider the webhook call failed. We don't recommend this but you can turn off this verification by setting the `verify_ssl` key in the `webhook-server` config file to `false`.
221+
When using an URL that starts with `https://` the package will verify if the SSL certificate of the receiving party is valid. If it is not, we will consider the webhook call failed. We don't recommend this, but you can turn off this verification by setting the `verify_ssl` key in the `webhook-server` config file to `false`.
222222

223223
You can also disable the verification per webhook call with the `doNotVerifySsl` method.
224224

@@ -231,7 +231,7 @@ WebhookCall::create()
231231

232232
### Adding meta information
233233

234-
You can add extra meta information to the webhook. This meta information will not be transmitted, it will only be used to pass to [the events this package fires](#events).
234+
You can add extra meta information to the webhook. This meta information will not be transmitted, and it will only be used to pass to [the events this package fires](#events).
235235

236236
This is how you can add meta information:
237237

@@ -244,7 +244,7 @@ WebhookCall::create()
244244

245245
### Adding tags
246246

247-
If you're using [Laravel Horizon](https://laravel.com/docs/5.8/horizon) for your queues you'll be happy to know that we support [tags](https://laravel.com/docs/5.8/horizon#tags).
247+
If you're using [Laravel Horizon](https://laravel.com/docs/5.8/horizon) for your queues, you'll be happy to know that we support [tags](https://laravel.com/docs/5.8/horizon#tags).
248248

249249
To add tags to the underlying job that'll perform the webhook call, simply specify them in the `tags` key of the `webhook-server` config file or use the `withTags` method:
250250

@@ -259,13 +259,13 @@ WebhookCall::create()
259259

260260
The package fires these events:
261261
- `WebhookCallSucceededEvent`: the remote app responded with a `2xx` response code.
262-
- `WebhookCallFailedEvent`: the remote app responded with a non `2xx` response code or it did not respond at all
262+
- `WebhookCallFailedEvent`: the remote app responded with a non `2xx` response code, or it did not respond at all
263263
- `FinalWebhookCalledFailedEvent`: the final attempt to call the webhook failed.
264264

265265
All these events have these properties:
266266

267267
- `httpVerb`: the verb used to perform the request
268-
- `webhookUrl`: the url to where the request was sent
268+
- `webhookUrl`: the URL to where the request was sent
269269
- `payload`: the used payload
270270
- `headers`: the headers that were sent. This array includes the signature header
271271
- `meta`: the array of values passed to the webhook with [the `meta` call](#adding-meta-information)
@@ -289,11 +289,11 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
289289

290290
### Security
291291

292-
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
292+
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
293293

294294
## Postcardware
295295

296-
You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.
296+
You're free to use this package, but if it makes it to your production environment, we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.
297297

298298
Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.
299299

@@ -306,7 +306,7 @@ We publish all received postcards [on our company website](https://spatie.be/en/
306306

307307
## Support us
308308

309-
Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).
309+
Spatie is a web design agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).
310310

311311
Does your business depend on our contributions? Reach out and support us on [Patreon](https://www.patreon.com/spatie).
312312
All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

0 commit comments

Comments
 (0)