barrel_server_api (barrel_server v1.2.1)
View SourceEmbeddable route table for the barrel REST/sync surface.
Exposes barrel's routes as a plain livery route list (and a compiled router) so a host livery application can mount them into its own service, optionally under a sub-path, and apply its own middleware. The route handlers live in barrel_server_http, barrel_server_sync, barrel_server_spaces, and barrel_server_mcp; this module only assembles the table.
Routes are grouped so an embedder can take just what it needs:
meta-/and/health(standalone only by default).db- database lifecycle, documents, bulk, find, query, changes, attachments, vector add.sync- the replication wire (/db/:db/_sync/*).timeline- branch, merge, lineage.search- vector/bm25/hybrid search.spaces- the agent layer (/spaces,/handoffs).mcp- the MCP endpoint (empty when disabled).
routes/0 returns the default DB surface (db, sync, timeline, search) that barrel-lite needs. The standalone service (barrel_server_http) takes groups => all.
Embedding (DB surface, host owns auth) needs no barrel_server supervisor; just start barrel and barrel_spaces, then:
Barrel = barrel_server_api:router(),
HostR1 = livery_router:nest(<<"/barrel">>, Barrel, HostRouter),
{ok, _} = livery:start_service(#{http => #{port => 8080},
router => HostR1,
middleware => HostAuthStack}).
Summary
Functions
The known route groups.
A compiled router for the default DB surface.
A compiled router for the selected groups. In addition to groups, Opts may carry prefix => binary() to mount the routes under a sub-path (equivalent to livery_router:nest/2).
The default DB-surface routes (db, sync, timeline, search).
Routes for the selected groups. Opts is #{groups => all | [group()]}; unknown group names fail loud.
Types
Functions
-spec groups() -> [group()].
The known route groups.
-spec router() -> livery_router:router().
A compiled router for the default DB surface.
-spec router(map()) -> livery_router:router().
A compiled router for the selected groups. In addition to groups, Opts may carry prefix => binary() to mount the routes under a sub-path (equivalent to livery_router:nest/2).
-spec routes() -> [route()].
The default DB-surface routes (db, sync, timeline, search).
Routes for the selected groups. Opts is #{groups => all | [group()]}; unknown group names fail loud.