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

Add static convenience methods to simplify creation of HtmxResponse.Builder #136

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

xhaggi
Copy link
Contributor

@xhaggi xhaggi commented Oct 25, 2024

I added some convenience methods to HtmxResponse to simplify the creation of the HtmxResponse.Builder in certain cases. Now you can write HtmxResponse.redirect("/redirect").build() instead of HtmxResponse.builder().redirect("/redirect").build().

@xhaggi
Copy link
Contributor Author

xhaggi commented Oct 28, 2024

@wimdeblauwe after using the builder in several projects, I find it a bit cumbersome. I had introduced the builder back then, only for the reason that HtmxRequest also had a builder. Now I think this was not such a good idea and would rather get rid of it and work directly with HtmxRequest / HtmxResponse, which makes things much easier. We could deprecate the builders and copy all builder methods directly to HtmxRequest / HtmxResponse. I don't see any breaking changes at the moment and we can safely remove the builder in 4.0. What do you think about this?

@checketts
Copy link
Collaborator

I second that approach and it aligns with the JTE usage I've been using where the builder is injected to the method and we make calls on it instead of the HtmxResponse (since it is immutable)

When deprecating the builder I would like to help make the JTE use case work with the changes.

@wimdeblauwe
Copy link
Owner

ok for me.

@xhaggi
Copy link
Contributor Author

xhaggi commented Oct 30, 2024

@wimdeblauwe should we support method chaining like the builder does? IMO this is not really necessary for HtmxRequest as we create it in the resolver. But what about HtmxResponse?

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.

3 participants