public interface HtmxRequest
This class can be used as a controller method argument to access
the htmx Request Headers.
@HxRequest
@Get("/users")
String users(HtmxRequest htmxRequest) {
if (htmxRequest.isBoosted()) {
...
}
}
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic HtmxRequest.Builderbuilder()Return a new builder for the HtmxRequest.Return the current URL of the browser when the htmx request was made.booleanIndicates that the request is via an element using hx-boost.booleanIndicates if the request is for history restoration after a miss in the local history cachebooleanReturn true if this is an Htmx request.Return the user response to an HX-Prompt.target()Return the id of the target element if it exists.Return the id of the triggered element if it exists.Return the name of the triggered element if it exists.
-
Field Details
-
EMPTY
Represents a non-Htmx request.
-
-
Method Details
-
builder
Return a new builder for the HtmxRequest. -
isHtmxRequest
boolean isHtmxRequest()Return true if this is an Htmx request. -
isBoosted
boolean isBoosted()Indicates that the request is via an element using hx-boost.- Returns:
- true if the request was made via HX-Boost, false otherwise
-
currentUrl
Return the current URL of the browser when the htmx request was made. -
isHistoryRestoreRequest
boolean isHistoryRestoreRequest()Indicates if the request is for history restoration after a miss in the local history cache- Returns:
- true if this request is for history restoration, false otherwise
-
promptResponse
Return the user response to an HX-Prompt. -
target
Return the id of the target element if it exists. -
triggerName
Return the name of the triggered element if it exists. -
triggerId
Return the id of the triggered element if it exists.
-