-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[BUG] When using Dependency Injection , Iris call new method everytime to create a new struct #1564
Comments
@sheunglaili In Iris we have two bindings mode, |
so for static , does that means we have to wire up our bean first ?
like that ? so what if there is a lot dependencies ? so what to wire it up ourselves before register them ? |
@kataras I have written some demo code in https://github.com/sheunglaili/iris-DI-issue you can see when you request it the GET localhost:8080/api/ , the log in server will indicate the dependency is reinitialized again. |
That was an issue because a dependency depend on other dependencies and you are right, if all accepted dependencies are static so the user of those should be static too. Fixed on master branch. Thanks a lot @sheunglaili! |
thanks a lot @kataras |
Is this problem solved? |
Describe the bug
When passing in New function into
When requesting endpoints , the New function will run again. Shouldn't the result of the new constructor be stored in some kind of bean factory instead ?
To Reproduce
Steps to reproduce the behavior:
Expected behavior
New function should be called once only , but not everytime when there is request.
Screenshots
the Json is the configuration I printed from environment struct new function.
the line beneath it is the log in controller method
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: