Skip to content

Commit

Permalink
better readme introduction
Browse files Browse the repository at this point in the history
  • Loading branch information
viezel committed Oct 20, 2020
1 parent 2ba0356 commit 02f6e41
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
[![Latest Version on Packagist](https://img.shields.io/packagist/v/viezel/webhooks.svg?style=flat-square)](https://packagist.org/packages/viezel/webhooks)
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/viezel/webhooks/run-tests?label=tests)](https://github.com/viezel/webhooks/actions?query=workflow%3Arun-tests+branch%3Amaster)


Simple and clear implementation of Webhooks.


## Installation

You can install the package via composer:
Expand All @@ -29,7 +27,7 @@ Route::middleware('auth:api')->prefix('api')->as('webhooks.api.')->group(functio
Route::get('hooks', Viezel\Webhooks\Controllers\API\ListWebhooks::class)->name('list');
Route::get('hooks/events', Viezel\Webhooks\Controllers\API\ListWebhookEvents::class)->name('events');
Route::post('hooks', Viezel\Webhooks\Controllers\API\CreateWebhook::class)->name('create');
Route::post('hooks/{id}', Viezel\Webhooks\Controllers\API\DeleteWebhook::class)->name('delete');
Route::delete('hooks/{id}', Viezel\Webhooks\Controllers\API\DeleteWebhook::class)->name('delete');
});
```

Expand Down Expand Up @@ -72,6 +70,45 @@ class PostUpdatedEvent implements ShouldDeliverWebhooks
}
```

Next you need to register all your events with the `WebhookRegistry`.
This is typically done in the boot method of a ServiceProvider.

```php
public function boot()
{
WebhookRegistry::listen(PostUpdatedEvent::class);
}
```

To check everything works as expected, go visit the webhooks events route. The default route is: `/api/hooks/events`.
It depends how you register the webhook routes.

### List available webhooks events

GET https://myapp.test/api/hooks/events

### List registered webhooks

GET https://myapp.test/api/hooks

### Register a webhook

POST https://myapp.test/api/hooks

```json
{
"events": [
"post:updated"
],
"url": "https://another-app.com/some/callback/route"
}
```

### Delete a webhook

DELETE https://myapp.test/api/hooks/{id}


## Testing

```bash
Expand Down

0 comments on commit 02f6e41

Please sign in to comment.