Last active
April 9, 2018 09:57
-
-
Save MaryamZi/138cf119d3bc54698afbf5db2b14155f to your computer and use it in GitHub Desktop.
Sample demonstrating usage of the GitHubWebhook service, introduced extending Ballerina's WebSub subscriber service.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ballerina/io; | |
import ballerina/http; | |
import ballerina/webhook; | |
import ballerina/websub; | |
endpoint webhook:GitHubListener githubListenerEP { | |
host:"localhost", | |
port:8181 | |
}; | |
@websub:SubscriberServiceConfig { | |
basePath:"/githubWebhook", | |
secret: "Kslk30SNF2AChs2" | |
} | |
service<webhook:GitHubService> githubWebhook bind githubListenerEP { | |
onIssueCommentCreated (websub:NotificationRequest notification) { | |
string notificationPayload = notification.payload.toString() but { () => "" }; | |
io:println("[onIssueCommentCreated] WebSub Notification Received: " + notificationPayload); | |
} | |
onIssueCommentEdited (websub:NotificationRequest notification) { | |
string notificationPayload = notification.payload.toString() but { () => "" }; | |
io:println("[onIssueCommentEdited] WebSub Notification Received: " + notificationPayload); | |
} | |
onIssueCommentDeleted (websub:NotificationRequest notification) { | |
string notificationPayload = notification.payload.toString() but { () => "" }; | |
io:println("[onIssueCommentDeleted] WebSub Notification Received: " + notificationPayload); | |
} | |
onIssuesEdited (websub:NotificationRequest notification) { | |
string notificationPayload = notification.payload.toString() but { () => "" }; | |
io:println("[onIssuesEdited] WebSub Notification Received: " + notificationPayload); | |
} | |
onWatch (websub:NotificationRequest notification) { | |
string notificationPayload = notification.payload.toString() but { () => "" }; | |
io:println("[onWatch] WebSub Notification Received: " + notificationPayload); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment