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

Integrating library that uses RequestMappingHandlerMapping #46

Open
kenpb opened this issue Mar 15, 2024 · 4 comments
Open

Integrating library that uses RequestMappingHandlerMapping #46

kenpb opened this issue Mar 15, 2024 · 4 comments

Comments

@kenpb
Copy link
Contributor

kenpb commented Mar 15, 2024

Hello,

I'm currently interested in integrating htmx-spring-boot; it's a set of helpers to work with htmx and avoid some boilerplate, the library provides a custom class that extends RequestMappingHandlerMapping for intercepting htmx specific endpoints.

If I add the dependencies and just run my example repo I would get a ClassCastException, I've tried adding the property plugin.pluginFirstClasses=HtmxRequestMappingHandlerMapping and plugin.pluginFirstClasses=io.github.wimdeblauwe.htmx.spring.boot.mvc.HtmxRequestMappingHandlerMapping to the config without any luck, maybe I didn't understand the right way to use this?

So my question is, if I were to integrate this library permanently without relaying in the config for it, how should proceed? Should I create a custom WebMvcRegistrations bean to override the one in SbpWebMvcPatchAutoConfiguration and provide an extended PluginRequestMappingHandlerMapping class that also to included the htmx handling? Or what would be a right way of handling this?

Salutations and thanks.

@hank-cp
Copy link
Owner

hank-cp commented Apr 8, 2024

Unfortunately, both htmx-spring-boot and sbp extend RequestMappingHandlerMapping to build underlying supports. So basically them are just not able to live together.

@kenpb
Copy link
Contributor Author

kenpb commented Apr 12, 2024

Hi @hank-cp , thanks for the reply and indeed, but thankfully, since the sbp and htmx override different parts of the RequestMappingHandlerMapping I did manage (in a hacky way) to get them to work together.

I created a custom WebMvcRegistrations that I registered before SbpWebMvcPatchAutoConfiguration and marked as primary, this class added a custom RequestMappingHandlerMapping that extended the PluginRequestMappingHandlerMapping and added the necessary RequestConditions to get htmx-spring-boot to work, it's less than ideal and I haven't tested anything besides the regular @HxRequest but if anyone is interested in doing something like that this code may be of help

WDYT?

@hank-cp
Copy link
Owner

hank-cp commented Apr 16, 2024

Your solution looks feasible. Could you make a PR for it please? It's better that you could also provide webflux support.

Thx in advance:)

@kenpb
Copy link
Contributor Author

kenpb commented Apr 21, 2024

Sure thing, just a little short on time ATM so I it may take a while before I can submit the PR

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