Skip to content

Commit c2b31b4

Browse files
committed
feat(verification webhooks): update hal browser documentation
1 parent 04ed1cc commit c2b31b4

File tree

5 files changed

+49
-107
lines changed

5 files changed

+49
-107
lines changed

lib/pact_broker/doc/controllers/app.rb

+12-2
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,26 @@ class App < Padrino::Application
1111
set :root, File.join(File.dirname(__FILE__), '..')
1212
set :show_exceptions, true
1313

14+
MAPPINGS = {
15+
'webhooks-create' => 'webhooks',
16+
'webhooks-webhooks' => 'webhooks',
17+
'pact-webhooks' => 'webhooks',
18+
}.freeze
19+
1420
helpers do
21+
def view_name_for rel_name
22+
MAPPINGS[rel_name] || rel_name
23+
end
24+
1525
def resource_exists? rel_name
16-
File.exist? File.join(self.class.root, 'views', "#{rel_name}.markdown")
26+
File.exist? File.join(self.class.root, 'views', "#{view_name_for(rel_name)}.markdown")
1727
end
1828
end
1929

2030
get ":rel_name" do
2131
rel_name = params[:rel_name]
2232
if resource_exists? rel_name
23-
markdown rel_name.to_sym, {:layout_engine => :haml, layout: :'layouts/main'}, {}
33+
markdown view_name_for(rel_name).to_sym, {:layout_engine => :haml, layout: :'layouts/main'}, {}
2434
else
2535
response.status = 404
2636
end

lib/pact_broker/doc/views/pact-webhooks.markdown

-50
This file was deleted.

lib/pact_broker/doc/views/webhooks-create.markdown

-38
This file was deleted.

lib/pact_broker/doc/views/webhooks-webhooks.markdown

-15
This file was deleted.

lib/pact_broker/doc/views/webhooks.markdown

+37-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Webhooks
22

3-
Allowed methods: GET, POST, DELETE
3+
Allowed methods (collection resource): `GET`, `POST`
4+
5+
Allowed methods (individual resource): `GET`, `PUT`, `DELETE`
46

57
### Creating
68

@@ -9,9 +11,12 @@ Allowed methods: GET, POST, DELETE
911
2. Click the "NON-GET" button for the "pact-webhooks" relation.
1012
3. Paste in the webhook JSON (example shown below) in the body section and click "Make Request".
1113

12-
An example webhook to trigger a Bamboo job.
14+
An example webhook to trigger a Bamboo job when a contract has changed.
1315

1416
{
17+
"events": [{
18+
"name": "contract_content_changed"
19+
}],
1520
"request": {
1621
"method": "POST",
1722
"url": "http://master.ci.my.domain:8085/rest/api/latest/queue/SOME-PROJECT?os_authType=basic",
@@ -26,6 +31,9 @@ An example webhook to trigger a Bamboo job.
2631
A request body can be specified as well.
2732

2833
{
34+
"events": [{
35+
"name": "contract_content_changed"
36+
}],
2937
"request": {
3038
"method": "POST",
3139
"url": "http://example.org/something",
@@ -37,6 +45,33 @@ A request body can be specified as well.
3745

3846
**BEWARE** The password can be reverse engineered from the database, so make a separate account for the Pact Broker to use, don't use your personal account!
3947

48+
#### Event types
49+
50+
`contract_content_changed:` triggered when the content of the contract has changed since the previous publication. Uses plain string equality, so changes to the ordering of hash keys, or whitespace changes will trigger this webhook.
51+
52+
`provider_verification_published:` triggered whenever a provider publishes a verification.
53+
54+
### Dynamic variable substitution
55+
56+
The following variables may be used in the request parameters or body, and will be replaced with their appropriate values at runtime.
57+
58+
`${pactbroker.pactUrl}`: the "permalink" URL to the newly published pact (the URL specifying the consumer version URL, rather than the "/latest" format.)
59+
60+
Example usage:
61+
62+
{
63+
"events": [{
64+
"name": "contract_content_changed"
65+
}],
66+
"request": {
67+
"method": "POST",
68+
"url": "http://example.org/something",
69+
"body": {
70+
"thisPactWasPublished" : "${pactbroker.pactUrl}"
71+
}
72+
}
73+
}
74+
4075
### Testing
4176

4277
To test a webhook, navigate to the webhook in the HAL browser, then make a POST request to the "execute" relation. The response or error will be shown in the window.

0 commit comments

Comments
 (0)