def decide.method

ezmcp@0.1.0.0 · src/rpc.bend:124

import ezmcp@0.1.0.0/src/rpc.bend as Rpc
import Base
import emerging-ezjson@1.2.0.0/main.bend as Json
import emerging-ezjson@1.2.0.0/src/value.bend as Value

124# a message with a method: a request when it has an id, which must be a
125# valid one; a notification when it has none
126def decide.method(
127  has_id: Bool,
128  id_ok: Bool,
129  id: Value.Json,
130  method: String,
131  params: Value.Json
132) -> Msg:
133  match has_id:
134    case False{}:
135      Tell{method, params}
136    case True{}:
137      Bool.pick(Msg, id_ok, Ask{id, method, params},
138        Junk{Json.null(), "Invalid Request: id must be a string or an integer"})

Uses (6)

Used by (1)