Skip to main content

Module api

Module api 

Source
Expand description

HTTP API type definition and handlers.

Ported from Haskell KB/API.hs and KB/API/Handlers.hs. Uses axum instead of Servant.

§Endpoints

  • GET /nodes/:id → 200 NodeView | 404
  • PUT /nodes/:id → UpdateNodeRequest → 200 NodeView | 404
  • DELETE /nodes/:id → 204 | 404
  • GET /nodes/:id/neighbors → 200 NeighborhoodResponse
  • POST /nodes?id=… → CreateNodeRequest → 201 NodeView | 409
  • GET /nodes?limit=&offset= → 200 NodeSummary
  • GET /search?q=… → 200 NodeSummary
  • GET /tags/:tag → 200 NodeSummary
  • GET /recent → 200 NodeSummary
  • POST /admin/relink → 200 RelinkResponse

§Content negotiation

Read/write endpoints honour text/org (with text/plain as a synonym) on both Content-Type (request) and Accept (response). An org request body is parsed via crate::parser; an org response renders the document via crate::generator. An org response carries the node id and timestamps in a leading :PROPERTIES: drawer (see crate::org_meta); a matching drawer on an org request body is stripped before storage. On PUT the drawer’s :ID:, when present, must equal the path id (a mismatch is 400); on POST it is discarded — callers wanting to set an id must use ?id=.

Structs§

AppState
Shared application state passed to all handlers.
CreateNodeQuery
POST /nodes query parameters.
CreateNodeRequest
POST /nodes body.
ListNodesQuery
GET /nodes query parameters.
NeighborEdge
One edge in a node’s link neighborhood.
NeighborhoodResponse
The link neighborhood of a node: outgoing and incoming edges.
NodeSummary
Compact node listing for search/tags/recent results.
NodeView
Full node response: identity, derived metadata, the AST, and timestamps.
RelinkResponse
The shape returned by POST /admin/relink.
SearchQuery
GET /search query parameters.
UpdateNodeRequest
PUT /nodes/:id body.

Constants§

REQUEST_BODY_LIMIT_BYTES
Maximum request body size for write-path handlers.

Functions§

build_router
Build the full axum Router for the KB API.