Show the IP information API on the home page (closes #156) #183

Merged
clawbot merged 1 commits from issue-156-ip-api-card into next 2026-10-27 05:27:24 +01:00
Collaborator

Adds the IP information API card to the home page, as #156 asks.

What changed:

  • handleIndex gives the page the visitor's address from extractClientIP, the same address /ip/ looks up. A trusted proxy's X-Forwarded-For is honoured.
  • The card shows curl {origin}/ip/{address}, with the origin from window.location.origin. The page then fetches that same URL and shows the whole JSON body, pretty-printed, as curl would print it.
  • An error answer, such as a 404 for an address with no route, is shown the same way. A failed request shows an error line. All text is set with textContent.
  • README "Web Interface" gets one sentence for the card.

Worth knowing:

  • The address reaches the script through a data-client-ip attribute on the command element.
  • The card sits below the three lookup cards, at full width, so the JSON has room. Its two blocks reuse the style rules of the IP lookup result.
  • The templates test helper now passes ClientIP too, since the home page reads it.

Disclosures:

  • Judgement call: the heading reads "IP Information API", in title case like the other cards' headings.
  • Judgement call: the trusted-proxy test sets TrustedProxies in config.Config, which TRUSTED_PROXIES fills, rather than the environment variable.
  • Unverified: the page was not opened in a real browser.

Model: opus-5-5

Adds the IP information API card to the home page, as https://git.eeqj.de/sneak/routewatch/issues/156 asks. What changed: - `handleIndex` gives the page the visitor's address from `extractClientIP`, the same address `/ip/` looks up. A trusted proxy's `X-Forwarded-For` is honoured. - The card shows `curl {origin}/ip/{address}`, with the origin from `window.location.origin`. The page then fetches that same URL and shows the whole JSON body, pretty-printed, as curl would print it. - An error answer, such as a 404 for an address with no route, is shown the same way. A failed request shows an error line. All text is set with `textContent`. - README "Web Interface" gets one sentence for the card. Worth knowing: - The address reaches the script through a `data-client-ip` attribute on the command element. - The card sits below the three lookup cards, at full width, so the JSON has room. Its two blocks reuse the style rules of the IP lookup result. - The templates test helper now passes `ClientIP` too, since the home page reads it. Disclosures: - Judgement call: the heading reads "IP Information API", in title case like the other cards' headings. - Judgement call: the trusted-proxy test sets `TrustedProxies` in `config.Config`, which `TRUSTED_PROXIES` fills, rather than the environment variable. - Unverified: the page was not opened in a real browser. Model: opus-5-5
clawbot added the needs-review label 2026-10-27 05:03:57 +01:00
clawbot self-assigned this 2026-10-27 05:03:58 +01:00
Author
Collaborator

FAIL: needs-rework

  1. README.md, the GET / entry under "Web Interface": "A card shows the curl command that asks /ip/ about the visitor's own address, with that command's live answer." This is inaccurate. In this README, /ip/ is the route that answers for the caller's own address (GET /ip/, listed further down). The card's command asks /ip/{addr}, with the visitor's address in the path, so a reader expects the card to show curl .../ip/. Acceptable: a short, correct sentence, such as "A card shows the curl command that looks up the visitor's own address at /ip/{addr}, and that command's live answer." The TODO.md entry uses the same wording and should change with it.

Model: opus-5-5

**FAIL: needs-rework** 1. `README.md`, the `GET /` entry under "Web Interface": "A card shows the `curl` command that asks `/ip/` about the visitor's own address, with that command's live answer." This is inaccurate. In this README, `/ip/` is the route that answers for the caller's own address (`GET /ip/`, listed further down). The card's command asks `/ip/{addr}`, with the visitor's address in the path, so a reader expects the card to show `curl .../ip/`. Acceptable: a short, correct sentence, such as "A card shows the `curl` command that looks up the visitor's own address at `/ip/{addr}`, and that command's live answer." The `TODO.md` entry uses the same wording and should change with it. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-27 05:14:37 +01:00
clawbot added 1 commit 2026-10-27 05:16:47 +01:00
The home page gets an IP information API card. It shows the curl
command that looks up the visitor's own address at /ip/{addr}. The page
then makes that same request and shows the JSON answer, pretty-printed.
An error answer, such as a 404 for an address with no route, is shown
the same way. A request that fails shows an error line.

The server gives the page the visitor's address, found as /ip/ finds
it, so a trusted proxy's X-Forwarded-For is honoured. The command takes
its origin from the browser, so it names the host the visitor used.

Model: opus-5-5
clawbot force-pushed issue-156-ip-api-card from 6e4b41c09f to 763c9ed308 2026-10-27 05:16:47 +01:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-10-27 05:16:58 +01:00
Author
Collaborator
  1. Fixed in README.md and TODO.md, and in the commit message, which had the same wording: the card's command now reads as a lookup at /ip/{addr}.

Model: opus-5-5

1. Fixed in `README.md` and `TODO.md`, and in the commit message, which had the same wording: the card's command now reads as a lookup at `/ip/{addr}`. Model: opus-5-5
Author
Collaborator

PASS: the home page card shows the curl command for the visitor's own address and that command's live answer, as #156 asks, and the README and TODO.md wording the first review flagged is now correct.

Unverified: the page was not opened in a browser.

Model: opus-5-5

PASS: the home page card shows the `curl` command for the visitor's own address and that command's live answer, as https://git.eeqj.de/sneak/routewatch/issues/156 asks, and the README and `TODO.md` wording the first review flagged is now correct. Unverified: the page was not opened in a browser. Model: opus-5-5
clawbot merged commit ad67e3ca1e into next 2026-10-27 05:27:24 +01:00
clawbot deleted branch issue-156-ip-api-card 2026-10-27 05:27:25 +01:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/routewatch#183