wimdeblauwe / htmx-spring-boot

Spring Boot and Thymeleaf helpers for working with htmx
Apache License 2.0
521 stars 49 forks source link

[feature request]: RedirectAttributes with .redirect() ? #96

Closed resmo closed 3 weeks ago

resmo commented 10 months ago

I don't know if this is even possible but it would be nice to have support for Springs RedirectAttributes when using

return HtmxResponse.builder()
          .redirect("/my-resource/1")
          .build();
wimdeblauwe commented 10 months ago

What do you want to make possible that is not possible now?

resmo commented 10 months ago

I'd like to have a replacement for

    @GetMapping("/test")
    public String testRedirect(RedirectAttributes redirAttrs) {
        redirAttrs.addFlashAttribute("success", "an example message");
        return "redirect:/";
    }

but with a HtmxResponse:

    @HxRequest
    @GetMapping("/test")
    public HtmxResponse testRedirectHx(RedirectAttributes redirAttrs) {
        redirAttrs.addFlashAttribute("success", "an example message");
        return HtmxResponse.builder()
                .redirect("/")
                .build();
    }
xhaggi commented 4 weeks ago

@resmo I had the same issue and fixed it in #137.