Skip to content

Commit

Permalink
Update string-template usage according to latest guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
ayeshLK committed Jun 14, 2021
1 parent a9b1481 commit 5c9b5a0
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion websub-ballerina/request_processor.bal
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ isolated function processEventNotification(http:Caller caller, http:Request requ
};
}
_ => {
log:printError(string`Unrecognized content-type [${contentType}] found`);
log:printError(string `Unrecognized content-type [${contentType}] found`);
}
}

Expand Down
8 changes: 4 additions & 4 deletions websub-ballerina/sub_listener.bal
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ isolated function retrieveCallbackUrl(string? providedCallback, boolean appendSe
if providedCallback is string {
if appendServicePath {
string completeSevicePath = retrieveCompleteServicePath(servicePath);
return string`${providedCallback}${completeSevicePath}`;
return string `${providedCallback}${completeSevicePath}`;
} else {
return providedCallback;
}
Expand All @@ -250,7 +250,7 @@ isolated function generateCallbackUrl(string[]|string servicePath,
string host = config.host;
string protocol = config.secureSocket is () ? "http" : "https";
string completeSevicePath = retrieveCompleteServicePath(servicePath);
return string`${protocol}://${host}:${port.toString()}${completeSevicePath}`;
return string `${protocol}://${host}:${port.toString()}${completeSevicePath}`;
}

# Retrieves the complete service path.
Expand Down Expand Up @@ -322,8 +322,8 @@ isolated function initiateSubscription(SubscriberServiceConfiguration serviceCon
SubscriptionChangeRequest request = retrieveSubscriptionRequest(topicUrl, callbackUrl, serviceConfig);
var response = subscriberClientEp->subscribe(request);
if response is SubscriptionChangeResponse {
string subscriptionSuccessMsg = string`Subscription Request successfully sent to Hub[${response.hub}], for Topic[${response.topic}], with Callback [${callbackUrl}]`;
log:printDebug(string`${subscriptionSuccessMsg}`);
string subscriptionSuccessMsg = string `Subscription Request successfully sent to Hub[${response.hub}], for Topic[${response.topic}], with Callback [${callbackUrl}]`;
log:printDebug(subscriptionSuccessMsg);
} else {
return response;
}
Expand Down
6 changes: 3 additions & 3 deletions websub-ballerina/tests/content_verification_test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function testOnEventNotificationSuccessForContentVerification() returns @tainted
http:Request request = new;
json payload = {"action":"publish","mode":"remote-hub"};
byte[] payloadHash = check retrievePayloadSignature(hashKey, payload);
request.setHeader("X-Hub-Signature", string`sha256=${payloadHash.toBase16()}`);
request.setHeader("X-Hub-Signature", string `sha256=${payloadHash.toBase16()}`);
request.setPayload(payload);
http:Response response = check contentVerificationClient->post("/", request);
test:assertEquals(response.statusCode, 202);
Expand All @@ -73,7 +73,7 @@ function testOnEventNotificationSuccessXmlForContentVerification() returns @tain
http:Request request = new;
xml payload = xml `<body><action>publish</action></body>`;
byte[] payloadHash = check retrievePayloadSignature(hashKey, payload);
request.setHeader("X-Hub-Signature", string`sha256=${payloadHash.toBase16()}`);
request.setHeader("X-Hub-Signature", string `sha256=${payloadHash.toBase16()}`);
request.setPayload(payload);
http:Response response = check contentVerificationClient->post("/", request);
test:assertEquals(response.statusCode, 202);
Expand All @@ -88,7 +88,7 @@ function testOnEventNotificationSuccessForUrlEncodedForContentVerification() ret
string payload = "param1=value1&param2=value2";
byte[] payloadHash = check retrievePayloadSignature(hashKey, payload);
request.setTextPayload(payload);
request.setHeader("X-Hub-Signature", string`sha256=${payloadHash.toBase16()}`);
request.setHeader("X-Hub-Signature", string `sha256=${payloadHash.toBase16()}`);
check request.setContentType(mime:APPLICATION_FORM_URLENCODED);
http:Response response = check contentVerificationClient->post("", request);
test:assertEquals(response.statusCode, 202);
Expand Down
4 changes: 2 additions & 2 deletions websub-ballerina/tests/subscription_initiation_test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ isolated function testSubscriptionInitiationFailureWithDiscoveryUrl() returns @t
test:assertTrue(response is ResourceDiscoveryFailedError);
if response is error {
string errorDetails = response.message();
string errorMsg = string`Subscription initiation failed due to: ${errorDetails}`;
string errorMsg = string `Subscription initiation failed due to: ${errorDetails}`;
log:printError(errorMsg);
}
}
Expand All @@ -85,7 +85,7 @@ isolated function testSubscriptionInitiationFailureWithHubAndTopic() returns @ta
test:assertTrue(response is SubscriptionInitiationError);
if response is error {
string errorDetails = response.message();
string errorMsg = string`Subscription initiation failed due to: ${errorDetails}`;
string errorMsg = string `Subscription initiation failed due to: ${errorDetails}`;
log:printError(errorMsg);
}
}
Expand Down
2 changes: 1 addition & 1 deletion websub-ballerina/utils.bal
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ isolated function retrieveContentHash(string method, string key, string payload)
return crypto:hmacSha512(contentPayload, keyArr);
}
_ => {
string errorMsg = string`Unrecognized hashning-method [${method}] found`;
string errorMsg = string `Unrecognized hashning-method [${method}] found`;
log:printError(errorMsg);
return error Error(errorMsg);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ service /subscriber on new websub:Listener(9090) {
int hookId = check retrievedContent.hook_id;
json sender = check retrievedContent.sender;
int senderId = check sender.id;
io:println(string`PingEvent received for webhook [${hookId}]`);
io:println(string`Event sender [${senderId}]`);
io:println(string `PingEvent received for webhook [${hookId}]`);
io:println(string `Event sender [${senderId}]`);
} else if (retrievedContent.ref is string) {
json repository = check retrievedContent.repository;
string repositoryName = check repository.name;
string lastUpdatedTime = check repository.updated_at;
io:println(string`PushEvent received for [${repositoryName}]`);
io:println(string`Last updated at ${lastUpdatedTime}`);
io:println(string `PushEvent received for [${repositoryName}]`);
io:println(string `Last updated at ${lastUpdatedTime}`);
}
} else {
io:println("Unrecognized content type, hence ignoring");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ service /subscriber on new websub:Listener(9090) {
int hookId = check retrievedContent.hook_id;
json sender = check retrievedContent.sender;
int senderId = check sender.id;
io:println(string`PingEvent received for webhook [${hookId}]`);
io:println(string`Event sender [${senderId}]`);
io:println(string `PingEvent received for webhook [${hookId}]`);
io:println(string `Event sender [${senderId}]`);
} else if (retrievedContent.ref is string) {
json repository = check retrievedContent.repository;
string repositoryName = check repository.name;
string lastUpdatedTime = check repository.updated_at;
io:println(string`PushEvent received for [${repositoryName}]`);
io:println(string`Last updated at ${lastUpdatedTime}`);
io:println(string `PushEvent received for [${repositoryName}]`);
io:println(string `Last updated at ${lastUpdatedTime}`);
}
} else {
io:println("Unrecognized content type, hence ignoring");
Expand Down

0 comments on commit 5c9b5a0

Please sign in to comment.