object

http_htmx

Transport-neutral HTMX request classification, HTML reply helpers, and response decoration helpers for normalized HTTP messages.

Availability:
logtalk_load(http_htmx(loader))
Author: Paulo Moura
Version: 1:0:0
Date: 2026-07-07
Compilation flags:
static, context_switching_calls
Remarks:
(none)

Public predicates

is_htmx_request/1

Succeeds when the request carries a truthy HX-Request header value.

Compilation flags:
static
Template:
is_htmx_request(Request)
Mode and number of proofs:
is_htmx_request(+compound) - zero_or_one

is_boosted_request/1

Succeeds when the request carries a truthy HX-Boosted header value.

Compilation flags:
static
Template:
is_boosted_request(Request)
Mode and number of proofs:
is_boosted_request(+compound) - zero_or_one

is_history_restore_request/1

Succeeds when the request carries a truthy HX-History-Restore-Request header value.

Compilation flags:
static
Template:
is_history_restore_request(Request)
Mode and number of proofs:
is_history_restore_request(+compound) - zero_or_one

is_fragment_request/1

Succeeds when the request should receive fragment content, meaning an HTMX request that is neither boosted nor a history restore request.

Compilation flags:
static
Template:
is_fragment_request(Request)
Mode and number of proofs:
is_fragment_request(+compound) - zero_or_one

request_kind/2

Classifies the request as one of ordinary, fragment, boosted, or history_restore.

Compilation flags:
static
Template:
request_kind(Request,Kind)
Mode and number of proofs:
request_kind(+compound,-atom) - one_or_error
Exceptions:

current_url/2

Returns the single request HX-Current-URL header value when present.

Compilation flags:
static
Template:
current_url(Request,URL)
Mode and number of proofs:
current_url(+compound,-atom) - zero_or_one

current_url_abs_path/2

Returns the same-origin absolute-path form of the HX-Current-URL header value, including any query component but excluding scheme, authority, and fragment.

Compilation flags:
static
Template:
current_url_abs_path(Request,AbsolutePath)
Mode and number of proofs:
current_url_abs_path(+compound,-atom) - zero_or_one

prompt/2

Returns the single request HX-Prompt header value when present.

Compilation flags:
static
Template:
prompt(Request,Prompt)
Mode and number of proofs:
prompt(+compound,-atom) - zero_or_one

target/2

Returns the single request HX-Target header value when present.

Compilation flags:
static
Template:
target(Request,Target)
Mode and number of proofs:
target(+compound,-atom) - zero_or_one

trigger/2

Returns the single request HX-Trigger header value when present.

Compilation flags:
static
Template:
trigger(Request,Trigger)
Mode and number of proofs:
trigger(+compound,-atom) - zero_or_one

trigger_name/2

Returns the single request HX-Trigger-Name header value when present.

Compilation flags:
static
Template:
trigger_name(Request,Name)
Mode and number of proofs:
trigger_name(+compound,-atom) - zero_or_one

request_properties/2

Returns a list of derived HTMX request properties and request classification computed from the normalized request headers.

Compilation flags:
static
Template:
request_properties(Request,Properties)
Mode and number of proofs:
request_properties(+compound,-list(compound)) - one_or_error
Exceptions:

request_property/2

Enumerates or tests individual derived HTMX request properties and request classification computed from the normalized request headers.

Compilation flags:
static
Template:
request_property(Request,Property)
Mode and number of proofs:
request_property(+compound,?compound) - zero_or_more

reply/3

Builds a normalized text/html response from a pre-rendered HTML atom or an html term/list using the default options.

Compilation flags:
static
Template:
reply(Request,Content,Response)
Mode and number of proofs:
reply(+compound,+term,-compound) - one_or_error
Exceptions:
Request is not a valid normalized HTTP request term:
domain_error(http_request,Request)
Content cannot be rendered as HTMX HTML content:
domain_error(http_htmx_content,Content)
The HTMX response status is invalid:
domain_error(htmx_response_headers_status,Status)
The generated response violates normalized HTTP response semantics:
domain_error(http_header_semantics,Header)

reply/4

Builds a normalized text/html response from a pre-rendered HTML atom or an html term/list using the given options.

Compilation flags:
static
Template:
reply(Request,Content,Response,Options)
Mode and number of proofs:
reply(+compound,+term,-compound,+list(compound)) - one_or_error
Exceptions:
Request is not a valid normalized HTTP request term:
domain_error(http_request,Request)
Content cannot be rendered as HTMX HTML content:
domain_error(http_htmx_content,Content)
Options is a variable or a partial list:
instantiation_error
Options is neither a variable nor a list:
type_error(list,Options)
An element Option of the list Options is neither a variable nor a compound term:
type_error(compound,Option)
An element Option of the list Options is a compound term but not a valid option:
domain_error(option,Option)
The HTMX response status is invalid:
domain_error(htmx_response_headers_status,Status)
The generated response violates normalized HTTP response semantics:
domain_error(http_header_semantics,Header)

page_fragment_reply/4

Builds a normalized text/html response using the fragment content when is_fragment_request/1 succeeds and the full-page content otherwise, with the default options.

Compilation flags:
static
Template:
page_fragment_reply(Request,PageContent,FragmentContent,Response)
Mode and number of proofs:
page_fragment_reply(+compound,+term,+term,-compound) - one_or_error
Exceptions:
Request is not a valid normalized HTTP request term:
domain_error(http_request,Request)
PageContent or FragmentContent cannot be rendered as HTMX HTML content:
domain_error(http_htmx_content,Content)
The HTMX response status is invalid:
domain_error(htmx_response_headers_status,Status)
The generated response violates normalized HTTP response semantics:
domain_error(http_header_semantics,Header)

page_fragment_reply/5

Builds a normalized text/html response using the fragment content when is_fragment_request/1 succeeds and the full-page content otherwise, with the given options.

Compilation flags:
static
Template:
page_fragment_reply(Request,PageContent,FragmentContent,Response,Options)
Mode and number of proofs:
page_fragment_reply(+compound,+term,+term,-compound,+list(compound)) - one_or_error
Exceptions:
Request is not a valid normalized HTTP request term:
domain_error(http_request,Request)
PageContent or FragmentContent cannot be rendered as HTMX HTML content:
domain_error(http_htmx_content,Content)
Options is a variable or a partial list:
instantiation_error
Options is neither a variable nor a list:
type_error(list,Options)
An element Option of the list Options is neither a variable nor a compound term:
type_error(compound,Option)
An element Option of the list Options is a compound term but not a valid option:
domain_error(option,Option)
The HTMX response status is invalid:
domain_error(htmx_response_headers_status,Status)
The generated response violates normalized HTTP response semantics:
domain_error(http_header_semantics,Header)

add_response_headers/4

Decorates a normalized response with the relevant HTMX response headers and optional cache-vary metadata.

Compilation flags:
static
Template:
add_response_headers(Request,Response0,Response,Options)
Mode and number of proofs:
add_response_headers(+compound,+compound,-compound,+list(compound)) - one_or_error
Exceptions:
Request is not a valid normalized HTTP request term:
domain_error(http_request,Request)
Response0 is not a valid normalized HTTP response term:
domain_error(http_response,Response0)
Options is a variable or a partial list:
instantiation_error
Options is neither a variable nor a list:
type_error(list,Options)
An element Option of the list Options is neither a variable nor a compound term:
type_error(compound,Option)
An element Option of the list Options is a compound term but not a valid option:
domain_error(option,Option)
The HTMX response status is invalid:
domain_error(htmx_response_headers_status,Status)
The decorated response violates normalized HTTP response semantics:
domain_error(http_header_semantics,Header)

Protected predicates

(no local declarations; see entity ancestors if any)

Private predicates

(no local declarations; see entity ancestors if any)

Operators

(none)