Skip to content

feat: serve API search over HTTP QUERY - #80

Merged
iuhoay merged 2 commits into
mainfrom
query-cli-search
Aug 22, 2026
Merged

iuhoay merged 2 commits into
mainfrom
query-cli-search

Conversation

@iuhoay

@iuhoay iuhoay commented Aug 22, 2026

Copy link
Copy Markdown
Owner

Server half of #71. Same Api::EntriesController#index, now reachable as QUERY with the query in the JSON body.

QUERY /api/entries
Authorization: Bearer …
Content-Type: application/json

{"q":"中","scope":"all","limit":20}
  • Puma 8 allowlists QUERY. Without this the request dies 501 in the parser, empty body, no x-runtime.
  • One named route, both verbs: match "entries", via: [:get, :query]. A GET-only resources#index never matches QUERY.
  • GET ?q= stays as the compatibility path. Inbox stays GET.
  • Tests cover unauthenticated QUERY (401), GET ?q=, QUERY JSON body, and a single-character CJK query.

Not in this PR: flipping drift search in iuhoay/drift-cli. Shipping QUERY in the client first dies with a blank 501.

After merge + deploy, probe before touching the CLI:

curl -X QUERY https://rdrift.app/api/entries   -H 'Content-Type: application/json'   --data '{"q":"hello"}'

Done when that is 401 (Rails reached the token check), not 501. Then split entries() in drift-cli: search uses QUERY + send_json; inbox stays GET.

Locally, after restarting Puma, unauthenticated QUERY on :3000 already returns 401 with x-runtime.

iuhoay added 2 commits August 22, 2026 20:27
Allowlist QUERY in Puma and draw GET|QUERY on /api/entries so the CLI
can put q in a JSON body. Inbox stays GET; GET ?q= remains as a
compatibility path. The action is unchanged.

Refs #71. Do not flip drift-cli until an unauthenticated QUERY against
production returns 401, not a blank Puma 501.
Keep resources :entries. query :index on the collection is the
canonical action, so the path stays /api/entries instead of tearing
the resource into match via: [:get, :query].
@iuhoay

iuhoay commented Aug 22, 2026

Copy link
Copy Markdown
Owner Author

CLI half is ready in iuhoay/drift-cli#1 — drift search sends QUERY + JSON body; inbox stays GET.

Held: do not merge or release that until this is deployed. Probe just now:

QUERY https://rdrift.app/api/entries

still 501, empty body, no x-runtime. Local :3000 on this branch is already 401.

CI here is green. Merge + deploy this first; flip the CLI after the probe returns 401.

@iuhoay
iuhoay merged commit 3751d6d into main Aug 22, 2026
5 checks passed
@iuhoay
iuhoay deleted the query-cli-search branch August 22, 2026 13:06
iuhoay added a commit to iuhoay/drift-cli that referenced this pull request Aug 22, 2026
Split entries(): inbox stays GET /api/entries. Search uses QUERY with
q/scope/limit in a JSON body so the query is not in the URL.

Refs iuhoay/drift#71. Follows iuhoay/drift#80 (now on production).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant