webhookd icon indicating copy to clipboard operation
webhookd copied to clipboard

Returning HTTP status codes

Open smox opened this issue 2 years ago • 4 comments

Hello,

I want to send errors back when the parameters are wrong and I think it is not a nice way to send an error back with 200 OK. Is there a way to set the HTTP status code of the response?

smox avatar Jan 25 '23 09:01 smox

Hello, the script execution is returned in real time by Webhookd using a streamed HTTP response (Server Sent Event). Because of that, the HTTP code is already sent before the script execution starts. Therefore a problem detected within the script cannot influence the return code.

ncarlier avatar Jan 25 '23 17:01 ncarlier

Thats a shame, I could see real value in a simple tool to run a script / tool and have the exit code of that script determine the http response code to the originating client making the request

johntdyer avatar Mar 22 '23 15:03 johntdyer

Would it be a possible way to disable SSE and therefore are able to send HTTP codes? This would really help.

LWlook avatar Jun 18 '24 16:06 LWlook

I'm working on an optional blocking mode. This allows you to obtain the HTTP response code relative to the script's output code. Here the behavior: https://github.com/ncarlier/webhookd/blob/7f3dfc472d243d5d586d0f01970074337a5d8715/README.md#webhook-call

ncarlier avatar Jun 22 '24 07:06 ncarlier