Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract resource name for http filters #27861

Closed
wants to merge 1 commit into from

Conversation

ldclakmal
Copy link
Member

Purpose

The resourceNode.name.value is evaluated as the resource name concatenated with the accessor and $ symbols. In order to engage HTTP filters, the exact resource name should be desugard in to the HTTP filter context.

Example 1:
resource function get sayHello is evaluated as "$get$sayHello" and converted by the PR as "sayHello"

Example 2:
resource function myAccessor sayHello is evaluated as "$myAccessor$sayHello" and converted by the PR as "sayHello"

Example 3:
resource function my\$Accessor say\$Hello is evaluated as "$my\$Accessor$say\$Hello" and converted by the PR as "sayHello"

Related to #27820
Related to ballerina-platform/ballerina-library#584

Check List

  • Read the Contributing Guide
  • Updated Change Log
  • Checked Tooling Support (#)
  • Added necessary tests
    • Unit Tests
    • Spec Conformance Tests
    • Integration Tests
    • Ballerina By Example Tests
  • Increased Test Coverage
  • Added necessary documentation
    • API documentation
    • Module documentation in Module.md files
    • Ballerina By Examples

@@ -233,6 +234,11 @@ private BLangSimpleVariable addFilterContextCreation(BLangFunction resourceNode,
return filterContextVar;
}

private String extractResourceName(BLangFunction resourceNode) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this method supposed to extract the resource paths?
say we have a resource function such as resource function get foo/bar/[int i]/[int j]() { } what is the expected behavior?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The objective of this function is to extract the resource name by removing the accessor part attached to it. The expected value for the given resource signature is "foo$bar$*$*" and this function returns that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack, I was confused with the term resourceName as resource functions doesn't have a name anymore. Shall we concatenate the text parts of this instead of removing from the generated string.

@ldclakmal ldclakmal added Team/PCModules Team/StandardLibs All Ballerina standard libraries labels Jan 15, 2021
@ldclakmal ldclakmal added this to the Ballerina Swan Lake - Alpha milestone Jan 15, 2021
@ldclakmal
Copy link
Member Author

The resourceNode.name.value is evaluating is correct according to the new service type changes. It should be fixed at ballerina/reflect module.
Related issue: ballerina-platform/ballerina-library#837

@ldclakmal ldclakmal closed this Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team/StandardLibs All Ballerina standard libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants