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

Callservice dataset example #62

Merged

Conversation

1000TurquoisePogs
Copy link
Member

Proposed changes

This adds a simple dataservice which calls the hello dataservice and returns its content. The purpose is to show how someone can use the callservice API.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

PR Checklist

Please delete options that are not relevant.

  • If the changes in this PR are meant for the next release / mainline, this PR targets the "staging" branch.
  • My code follows the style guidelines of this project (see: Contributing guideline)
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • New and existing unit tests pass locally with my changes
  • video or image is included if visual changes are made
  • Relevant update to CHANGELOG.md
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works, or describe a test method below

Testing

Try calling POST /ZLUX/plugins/org.zowe.zlux.sample.angular/services/callservice/_current/ with various bodies, such as

  1. no body
  2. simple text
  3. simple JSON
    You should see that the contents returned are a JSON message that includes within a message that is identical to what you would have received if you had used the same body to call POST /ZLUX/plugins/org.zowe.zlux.sample.angular/services/hello/_current/
    This will prove that the callService API call was successful.

Further comments

Copy link
Contributor

@lchudinov lchudinov left a comment

Choose a reason for hiding this comment

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

It works fine to me so I approve it.

});
context.addBodyParseMiddleware(router);
router.post('/',function(req: Request,res: Response) {
(req as any).zluxData.plugin.callService('hello', '', {method:'POST', body: req.body, contentType:"text/plain"}).then((callRes)=> {
Copy link
Contributor

@lchudinov lchudinov Aug 3, 2021

Choose a reason for hiding this comment

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

I am curious why do we need to pass text/plain unconditionally. What if we pass an original content-type as req.body['content-type'] or omit it at all?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, its an oversight. I will fix it.

Signed-off-by: 1000TurquoisePogs <[email protected]>
@1000TurquoisePogs 1000TurquoisePogs merged commit 37944eb into zowe:staging Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants