webhook

Webhook usage process

Configuration
  1. # Whether to start the webhook admin service
  2. eventMesh.webHook.admin.start=true
  3. # webhook event configuration storage mode. But currently only supports file and nacos
  4. eventMesh.webHook.operationMode=file
  5. # The file path of fileMode. If you write #{eventMeshHome}, in the eventMesh root directory
  6. eventMesh.webHook.fileMode.filePath= #{eventMeshHome}/webhook
  7. # The nacos storage mode. The configuration naming rule is eventMesh.webHook.nacosMode.{nacos native configuration key} For the specific configuration, please see [nacos github api](https://github.com/alibaba/nacos/blob/develop/api/src/main/java /com/alibaba/nacos/api/SystemPropertyKeyConst.java)
  8. ## address of nacos
  9. eventMesh.webHook.nacosMode.serverAddr=127.0.0.1:8848
  10. # webhook eventcloud send mode. Same as eventMesh.connector.plugin.type configuration
  11. eventMesh.webHook.producer.connector=standalone

The second step: Add webhook configuration information

Configuration information description

  1. /**
  2. * The path called by the manufacturer. Manufacturer event call address, [http or https]://[domain or IP]:[port]/webhook/[callbackPath]
  3. * for example: http://127.0.0.1:10504/webhook/test/event , The full url needs to be filled in the manufacturer call input
  4. * callbackPath is the only
  5. */
  6. private String callbackPath;
  7. /**
  8. * manufacturer name, like github
  9. */
  10. private String manufacturerName;
  11. /**
  12. * webhook event name, like rep-push
  13. */
  14. private String manufacturerEventName;
  15. /**
  16. * http header content type
  17. */
  18. private String contentType = "application/json";
  19. /**
  20. * description of this WebHookConfig
  21. */
  22. private String description;
  23. /**
  24. * secret key, for authentication
  25. */
  26. private String secret;
  27. /**
  28. * userName, for HTTP authentication
  29. */
  30. private String userName;
  31. /**
  32. * password, for HTTP authentication
  33. */
  34. private String password;
  35. /**
  36. * roll out event name, like topic to mq
  37. */
  38. private String cloudEventName;
  39. /**
  40. * roll out data format -> CloudEvent serialization mode
  41. * If HTTP protocol is used, the request header contentType needs to be marked
  42. */
  43. private String dataContentType = "application/json";;
  44. /**
  45. * source of event
  46. */
  47. private String cloudEventSource;
  48. /**
  49. * id of cloudEvent, like uuid/manufacturerEventId
  50. */
  51. private String cloudEventIdGenerateMode;
Add webhook config

path: /webhook/insertWebHookConfig method: POST contentType: application/json

input params:

fielddesctype necessarydefault 
callbackPathcall address, unique addressstringY null 
manufacturerNamemanufacturer namestringY null 
manufacturerEventNamemanufacturer EventNamestringY null 
contentTypehttp connettypestringN application/json 
descriptionconfiguration instructionsstringN null 
secretsignature stringstringN null 
userNameusernamestringN null 
passwordpasswordstringN null 
cloudEventNamecloudEvent namestringY null 
cloudEventSourcecloudEvent sourcestringY null 
cloudEventIdGenerateModecloudEvent event object identification method, uuid or event idstringN manufacturerEventId 

E.g:

  1. {
  2. "callbackPath":"/webhook/github/eventmesh/all",
  3. "manufacturerName":"github",
  4. "manufacturerEventName":"all",
  5. "secret":"eventmesh",
  6. "cloudEventName":"github-eventmesh",
  7. "cloudEventSource":"github"
  8. }

Output params: 1 for success, 0 for failure

delete webhook config

path: /webhook/deleteWebHookConfig method: POST contentType: application/json

input params:

fielddesctype necessarydefault 
callbackPathcall address, unique addressstringY null 

E.g:

  1. {
  2. "callbackPath":"/webhook/github/eventmesh/all"
  3. }

Output params: 1 for success, 0 for failure

select WebHookConfig by callbackPath

path: /webhook/queryWebHookConfigById method: POST contentType: application/json

input params:

fielddesctype necessarydefault 
callbackPathcall address, unique addressstringY null 

E.g:

  1. {
  2. "callbackPath":"/webhook/github/eventmesh/all"
  3. }

Output params:

fielddesctype necessarydefault 
callbackPathcall address, unique addressstringY null 
manufacturerNamemanufacturer namestringY null 
manufacturerEventNamemanufacturer event namestringY null 
contentTypehttp connettypestringN application/json 
descriptionconfiguration instructionsstringN null 
secretsignature keystringN null 
userNameuser namestringN null 
passwordpasswordstringN null 
cloudEventNamecloudEvent namestringY null 
cloudEventSourcecloudEvent sourcestringY null 
cloudEventIdGenerateModecloudEvent event object identification method, uuid or event idstringN manufacturerEventId 
通过manufacturer查询WebHookConfig列表

path: /webhook/queryWebHookConfigByManufacturer method: POST contentType: application/json

input params:

fielddesctype necessarydefault 
manufacturerNamemanufacturer namestringY null 

E.g:

  1. {
  2. "manufacturerName":"github"
  3. }

Output params:

fielddesctype necessarydefault 
callbackPathcall address, unique addressstringY null 
manufacturerNamemanufacturer namestringY null 
manufacturerEventNamemanufacturer event namestringY null 
contentTypehttp connettypestringN application/json 
descriptionconfiguration instructionsstringN null 
secretsignature keystringN null 
userNameuser namestringN null 
passwordpasswordstringN null 
cloudEventNamecloudEvent namestringY null 
cloudEventSourcecloudEvent sourcestringY null 
cloudEventIdGenerateModecloudEvent event object identification method, uuid or event idstringN manufacturerEventId 

The third step: Check if the configuration is successful

  1. file storage mode. Please go to the eventMesh.webHook.fileMode.filePath directory to view. filename callbackPath.

  2. nacos storage mode. Please go to the nacos service configured by eventMesh.webHook.nacosMode.serverAddr to see.

The fourth step: Configure the consumer of cloudevent

For manufacturer’s operation, please refer to [Manufacturer’s webhook operation instructions] .

Manufacturer’s webhook operation instructions

github sign up

The first step: Enter the corresponding project

The second step: click setting

webhook - 图1

The third step: click Webhooks

webhook - 图2

The fourth step: Click on Add webhook

webhook - 图3

The fifth step: Fill in the webhook information

webhook - 图4

Payload URL: Service address and pahts. [http or https]://[domain or IP]:[port]/webhook/[callbackPath] Content type: http header content type secret: signature string