def server.handle

bend-kit-camber@0.15.0.1 · camber.bend:1101

import bend-kit-camber@0.15.0.1/camber.bend as Camber
import Base
import bend-kit-http@0.38.1.1/http.bend as Http
import bend-kit-http@0.38.1.1/completion.bend as TransportCompletion
import bend-kit-time@0.3.0.0/time.bend as Time

1101def server.handle(~A: Data, ~S: Type, ~K: Data, ~H: Data,
1102  ~done: TransportCompletion.Completion<NoticePayload<K, H>> -> IO(Unit),
1103  context: ServingContext<A, S, K, H>, req: Http.Req
1104) -> IO(Http.Reply):
1105  ServingContext{+app, owner} = context
1106  Application{table, config, root, groups} = app
1107  Http.Req{method, target, headers, body} = req
1108  do IO<Http.Reply>:
1109    started : Time.Duration <- Time.mono()
1110    +body_channel : Chan(Http.Body) <- Chan.new(Http.Body, 1)
1111    +response_channel : Chan(Http.Res) <- Chan.new(Http.Res, 1)
1112    sent : Result<&1, &1, Http.Body, Unit> <- Chan.send(Http.Body, body_channel, body)
1113    outcome : Outcome<Unit, ApplicationReport<H>> <- call(S, Application<A, K, Policy<H>>, BufferedRequest, Unit, ApplicationReport<H>,
1114      owner, app, BufferedRequest{Metadata{method, target, headers}, body_channel, response_channel})
1115    server.response(~K, ~H, ~done, config, started, outcome, body_channel, response_channel)

Uses (24)

Used by (1)