MCPcopy Create free account
hub / github.com/asternic/wuzapi / routeRequest

Method routeRequest

stdio.go:195–474  ·  view source on GitHub ↗
(req *jsonRpcRequest)

Source from the content-addressed store, hash-verified

193}
194
195func (ss *stdioServer) routeRequest(req *jsonRpcRequest) {
196 // Map stdio method to HTTP route and method
197 var httpMethod, httpPath string
198
199 switch req.Method {
200 case "health":
201 httpMethod = "GET"
202 httpPath = "/health"
203
204 // Admin user management
205 case "admin.users.add":
206 httpMethod = "POST"
207 httpPath = "/admin/users"
208 case "admin.users.list":
209 httpMethod = "GET"
210 httpPath = "/admin/users"
211 case "admin.users.get":
212 httpMethod = "GET"
213 userId, ok := ss.getUserIdParam(req)
214 if !ok {
215 // Error sent by getUserIdParam.
216 return
217 }
218 httpPath = "/admin/users/" + userId
219 case "admin.users.delete":
220 httpMethod = "DELETE"
221 userId, ok := ss.getUserIdParam(req)
222 if !ok {
223 // Error sent by getUserIdParam.
224 return
225 }
226 httpPath = "/admin/users/" + userId
227 case "admin.users.edit":
228 httpMethod = "PUT"
229 userId, ok := ss.getUserIdParam(req)
230 if !ok {
231 // Error sent by getUserIdParam.
232 return
233 }
234 httpPath = "/admin/users/" + userId
235 case "admin.users.delete.full":
236 httpMethod = "DELETE"
237 userId, ok := ss.getUserIdParam(req)
238 if !ok {
239 // Error sent by getUserIdParam.
240 return
241 }
242 httpPath = "/admin/users/" + userId + "/full"
243
244 // Session management
245 case "session.connect":
246 httpMethod = "POST"
247 httpPath = "/session/connect"
248 case "session.qr":
249 httpMethod = "GET"
250 httpPath = "/session/qr"
251 case "session.status":
252 httpMethod = "GET"

Callers 1

handleRequestMethod · 0.95

Calls 3

getUserIdParamMethod · 0.95
sendErrorMethod · 0.95
executeHTTPHandlerMethod · 0.95

Tested by

no test coverage detected