WardrikHTTP (wardrik_http v0.1.0-rc.1)
Copy MarkdownServes Wardrik's operations over HTTP.
Most apps use Wardrik.HTTP, which sets :server and :sign_in for you:
children = [MyApp.AgentRuntime, {Wardrik.HTTP, wardrik: MyApp.AgentRuntime, port: 4000}]Use WardrikHTTP directly to serve any Wardrik.Server:
children = [{WardrikHTTP, server: {Wardrik, MyApp.AgentRuntime}, port: 4000}]It's also a Plug, so your router can forward a path to it.
Options
:server- required.{module, name}: theWardrik.Servermodule, and the instance name it runs. RaisesArgumentErrorwithout it.:authenticator- aWardrikHTTP.Authenticator, as{module, config}.{WardrikHTTP.Bearer, []}unless set.:sign_in-{module, function, args}returning the{plug, opts}that serves sign-in pages, ornil.nilunless set.:keepalive- milliseconds an idle event stream waits before sending a comment.15_000.
As a child, it also takes Bandit's options, like :port and :ip.
Routes
| Route | Serves |
|---|---|
| each operation's route | every operation in WardrikProtocol, as JSON |
the same, with Accept: text/event-stream | streaming operations, as server-sent events |
GET /v1/openapi.json | the OpenAPI document |
GET /v1/workers | the tool workers' WebSocket. See WardrikHTTP.Worker. |
POST /v1/channels/{channel}/{path} | a chat app's request, relayed to the channel and back |
/oauth/* | sign-in pages, from :sign_in |
GET /v1/workers returns 426 to a request with a valid token that isn't a WebSocket upgrade,
so a worker can check its token first.
Every response has a request-id header. It's the caller's own if the request sent one.
Summary
Functions
Returns a child spec that serves with Bandit. Options not listed above go to Bandit.
Functions
@spec child_spec(keyword()) :: Supervisor.child_spec()
Returns a child spec that serves with Bandit. Options not listed above go to Bandit.