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

Examples with inversify unsafe with setHeaders #809

Closed
2 of 4 tasks
calvinwyoung opened this issue Oct 7, 2020 · 2 comments
Closed
2 of 4 tasks

Examples with inversify unsafe with setHeaders #809

calvinwyoung opened this issue Oct 7, 2020 · 2 comments

Comments

@calvinwyoung
Copy link

Sorting

  • I'm submitting a ...

    • bug report
    • feature request
    • support request
  • I confirm that I

    • used the search to make sure that a similar issue hasn't already been submit

Detailed Description

This is a request for clarification in the docs, and not a bug in the actual code.

The docs give examples for how to integrate tsoa with inversify (link). That part of the documentation also states that We usually don't want to create a new controller instance for every call, so let's create a convenience wrapper around @fluentProvide(), and provides an example of binding a controller to the IOC container in the singleton scope.

This is very reasonable — no point instantiating new controller instances if not necessary, so let's re-use the same instance for each request. However, since the Controller.setHeaders method mutates the controller state, calling setHeaders will modify the headers for every subsequent request to the same controller instance. This is pretty surprising, and took me a while to debug.

Would it be possible to clarify this behavior in the docs?

@WoH
Copy link
Collaborator

WoH commented Oct 8, 2020

You're correct here, could you open this ticket in the docs repo? @tsoa-community/docs

@calvinwyoung
Copy link
Author

Yes, no problem — sorry I hadn't realized that didn't belong here. I just created a new issue here: tsoa-community/docs#14

Thanks for your work maintaining this library @WoH!

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

No branches or pull requests

2 participants