wimdeblauwe / htmx-spring-boot

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

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

Open resmo opened 6 months ago

resmo commented 6 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 6 months ago

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

resmo commented 6 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();
    }