maragudk / maragudk/gomponents-htmx

htmx 4: update http package headers

Open
#23 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
124
Forks
5
PR merge metrics
No merged PRs in 30d

Description

Part of #18. Reference: https://four.htmx.org/reference/headers and the header tables in https://four.htmx.org/docs/whats-new-in-htmx-4

## Request headers

- Remove `GetTrigger` (`HX-Trigger` request header replaced by `HX-Source`).
- Remove `GetTriggerName` (folded into `HX-Source`).
- Remove `GetPrompt` (extension only).
- Add `GetSource` for `HX-Source`: the triggering element as `tag#id`, e.g. `button#submit`.
- Add `GetRequestType` for `HX-Request-Type`: `"full"` or `"partial"`.
- `GetTarget` value format changed from bare id to `tag#id` (or just the tag when there is no id). Update the doc comment; no parsing helper.

## Response headers

- Remove `SetTriggerAfterSettle` and `SetTriggerAfterSwap` (fold into `HX-Trigger`).
- Add `SetReselect` for `HX-Reselect` (exists in htmx 2 as well, never added here).
- `SetTrigger` doc: events now fire after the swap completes and support a `target` key.

Unchanged: `IsRequest`, `IsBoosted`, `GetCurrentURL`, `IsHistoryRestoreRequest`, `SetLocation`, `SetPushURL`, `SetRedirect`, `SetRefresh`, `SetReplaceURL`, `SetReswap`, `SetRetarget`.

## Acceptance criteria

- The table-driven tests in `http/http_test.go` cover exactly the htmx 4 header set.
- Package doc links to https://four.htmx.org/reference/headers

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the existing helpers in the http package and the table-driven tests in http/http_test.go, then compare them with the htmx 4 header reference. Done means the tests cover exactly the requested htmx 4 header set, including additions, removals, and format changes, and the package documentation links to the htmx 4 reference.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
82/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.