def act

ezmcp@0.1.0.0 · src/web.bend:29

import ezmcp@0.1.0.0/src/web.bend as Web
import Base
import ezmcp@0.1.0.0/src/server.bend as Server

29# a server's act, under revision `rev`, as an HTTP reply: a request's reply
30# is 200 with its JSON, a notification or a response is 202 with no body, a
31# message the server cannot accept is 400 with its error
32def act(rev: String, lead: Server.Act) -> Web:
33  match lead:
34    case Server.Quiet{}:
35      Now{202, [], ""}
36    case Server.Send{reply}:
37      json.reply(200, reply)
38    case Server.Fault{reply}:
39      json.reply(400, reply)
40    case Server.Run{id, name, args}:
41      Later{rev, id, name, args}
42    case Server.Batch{acts}:
43      Many{rev, acts}

Uses (5)

Used by (1)