From d40d81ab3e284f1297518f6ff64ee7243df18594 Mon Sep 17 00:00:00 2001 From: Daniel Kluge Date: Mon, 1 Jan 2024 17:30:44 +0100 Subject: [PATCH] Last stuff for the if server --- example/src/modules/httpInterfaceServer.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/example/src/modules/httpInterfaceServer.ts b/example/src/modules/httpInterfaceServer.ts index d24e672..f983baa 100644 --- a/example/src/modules/httpInterfaceServer.ts +++ b/example/src/modules/httpInterfaceServer.ts @@ -218,8 +218,14 @@ export default class HTTPInterfaceServer extends AbstractInterfaceServer if (op === null || !AASCoreTypes.isOperation(op)) return res.status(404).end(); try { - this.onRequestCallback({ type: "invokeAction", target: op, extraData: { args: req.body, async: false } }); - return res.send(204).end(); + // This will probably need some rework in production code + const result = this.onRequestCallback({ type: "invokeAction", target: op, extraData: { args: req.body, async: false } }); + if (result) { + if (req.accepts("json")) res.setHeader("content-type", "application/json"); + return res.status(200).send(result).end(); + } else { + return res.status(204).end(); + } } catch { return res.status(500).end(); }