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

Http client docs #716

Merged
merged 4 commits into from
Jul 11, 2019
Merged

Http client docs #716

merged 4 commits into from
Jul 11, 2019

Conversation

ZacharyKlein
Copy link
Member

No description provided.

@ZacharyKlein
Copy link
Member Author

@graemerocher could you clarify this? The client should be defined as a spring bean

As far as I know, the HTTP client has to be created via the create method, not a constructor call. I'm not sure how to define a Spring bean (e.g., in resources.groovy) where a method other than the constructor is being used. Or am I misunderstanding your statement?

@graemerocher
Copy link
Member

@ZacharyKlein how to define a bean that is created via a factory method is described in the Grails docs http://docs.grails.org/latest/guide/spring.html#theBeanBuilderDSLExplained

@ZacharyKlein
Copy link
Member Author

ZacharyKlein commented Jul 9, 2019

@graemerocher I experimented (with some help from James) and this is the closest I can get to defining a HttpClient bean:

beans = {
    httpClient(HttpClient) { bean ->
        bean.factoryMethod = "create"
        bean.constructorArgs = ["http://localhost:8080/api/widget".toURL()]
        bean
    }
}

However, this fails to start as a required bean of type io.micronaut.context.BeanContext cannot be found. Is there a way to get a ref of the Micronaut parent context and make that available to the httpClient bean? Or am I going about this wrong?

@graemerocher graemerocher merged commit 12d2c49 into master Jul 11, 2019
@puneetbehl puneetbehl deleted the http-client branch April 3, 2024 23:43
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