-
Notifications
You must be signed in to change notification settings - Fork 58
Add missing annotations for response headers #118
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
Merged
wimdeblauwe
merged 9 commits into
wimdeblauwe:main
from
xhaggi:missing-response-header-annotation-support
May 5, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
92db933
Add annotation support for HX-Location
xhaggi e52e3f6
Add annotation support for HX-Replace-Url
xhaggi 0708d1c
Add annotation support for HX-Redirect
xhaggi 788b1c0
Add annotation support for HX-Push-Url
xhaggi 7dcfdfe
Add annotation support for HX-Reswap
xhaggi c8669d3
Add annotation support for HX-Retarget
xhaggi 9e8f235
Add annotation support for HX-Reselect
xhaggi 381de86
Add dedicated annotations for HX-Trigger-After-Settle and HX-Trigger-…
xhaggi eb12958
Add and adjust methods to use HtmxResponseHeader instead of String to…
xhaggi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
htmx-spring-boot/src/main/java/io/github/wimdeblauwe/htmx/spring/boot/mvc/HtmxValue.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package io.github.wimdeblauwe.htmx.spring.boot.mvc; | ||
|
|
||
| /** | ||
| * Holder for constant values. | ||
| */ | ||
| public class HtmxValue { | ||
|
|
||
| /** | ||
| * Constant for use in annotations that support a {@code false} value to disable functions. | ||
| */ | ||
| public static final String FALSE = "false"; | ||
|
|
||
| /** | ||
| * Constant for use in annotations that support a {@code true} value to enable functions. | ||
| */ | ||
| public static final String TRUE = "true"; | ||
|
|
||
| } |
55 changes: 55 additions & 0 deletions
55
htmx-spring-boot/src/main/java/io/github/wimdeblauwe/htmx/spring/boot/mvc/HxLocation.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package io.github.wimdeblauwe.htmx.spring.boot.mvc; | ||
|
|
||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| import org.springframework.core.annotation.AliasFor; | ||
|
|
||
| /** | ||
| * Annotation to do a client side redirect that does not do a full page reload. | ||
| * <p> | ||
| * Note that this annotation does not provide support for specifying {@code values} or {@code headers}. | ||
| * If you want to do this, use {@link HtmxResponse} instead. | ||
| * | ||
| * @see <a href="https://htmx.org/headers/hx-location/">HX-Location Response Header</a> | ||
| */ | ||
| @Target({ElementType.TYPE, ElementType.METHOD}) | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| public @interface HxLocation { | ||
|
|
||
| /** | ||
| * The url path to make the redirect. | ||
| * <p>This is an alias for {@link #path}. For example, | ||
| * {@code @HxLocation("/foo")} is equivalent to | ||
| * {@code @HxLocation(path="/foo")}. | ||
| */ | ||
| @AliasFor("path") | ||
| String value() default ""; | ||
| /** | ||
| * The url path to make the redirect. | ||
| */ | ||
| String path() default ""; | ||
| /** | ||
| * The source element of the request | ||
| */ | ||
| String source() default ""; | ||
| /** | ||
| * An event that "triggered" the request | ||
| */ | ||
| String event() default ""; | ||
| /** | ||
| * A callback that will handle the response HTML. | ||
| */ | ||
| String handler() default ""; | ||
| /** | ||
| * The target to swap the response into. | ||
| */ | ||
| String target() default ""; | ||
| /** | ||
| * How the response will be swapped in relative to the target | ||
| */ | ||
| String swap() default ""; | ||
|
|
||
| } | ||
31 changes: 31 additions & 0 deletions
31
htmx-spring-boot/src/main/java/io/github/wimdeblauwe/htmx/spring/boot/mvc/HxPushUrl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package io.github.wimdeblauwe.htmx.spring.boot.mvc; | ||
|
|
||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| /** | ||
| * Annotation to push a URL into the browser | ||
| * <a href="https://developer.mozilla.org/en-US/docs/Web/API/History_API">location history</a>. | ||
| * <p> | ||
| * The possible values are: | ||
| * <ul> | ||
| * <li>{@link HtmxValue#TRUE}, which pushes the fetched URL into history.</li> | ||
| * <li>{@link HtmxValue#FALSE}, which disables pushing the fetched URL if it would otherwise be pushed.</li> | ||
| * <li>A URL to be pushed into the location bar. This may be relative or absolute, | ||
| * as per <a href="https://developer.mozilla.org/en-US/docs/Web/API/History/pushState">history.pushState()</a>.</li> | ||
| * </ul> | ||
| * | ||
| * @see <a href="https://htmx.org/headers/hx-push-url/">HX-Push-Url Response Header</a> | ||
| */ | ||
| @Target({ElementType.TYPE, ElementType.METHOD}) | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| public @interface HxPushUrl { | ||
|
|
||
| /** | ||
| * The value for the {@code HX-Push-Url} response header. | ||
| */ | ||
| String value() default HtmxValue.TRUE; | ||
|
|
||
| } |
22 changes: 22 additions & 0 deletions
22
htmx-spring-boot/src/main/java/io/github/wimdeblauwe/htmx/spring/boot/mvc/HxRedirect.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package io.github.wimdeblauwe.htmx.spring.boot.mvc; | ||
|
|
||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| /** | ||
| * Annotation to do a client-side redirect to a new location. | ||
| * | ||
| * @see <a href="https://htmx.org/reference/#response_headers">HX-Redirect</a> | ||
| */ | ||
| @Target({ElementType.TYPE, ElementType.METHOD}) | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| public @interface HxRedirect { | ||
|
|
||
| /** | ||
| * The URL to use to do a client-side redirect to a new location. | ||
| */ | ||
| String value(); | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.