Where can I find, in the Suave docs, the way to return an http error with a message as a plain text error?
I keep looking and I just can't find my way through the docs since it's structured as bits of examples here and there.
What I would like to do is this:
if thingsGoWell then
OK myResult
else
ERROR someHttpStatusCode myString
I know I can use the presets, like
INTERNAL_ERROR "hello"
but I want to be able to pass my own HttpStatusCode.
I'm just beginning to use Suave, I like the concepts so far but I'm really struggling with the documentation style.
I think you're looking for the basic
responsefunction:Documentation is here. Usage is like this:
I agree with you that the Suave documentation isn't great. Personally, I often answer questions like this by simply looking in the source code, which is here. I have a local copy that I've cloned and built. It's pretty easy, actually.
As an example, in this case, I searched for "INTERNAL_ERROR", since you gave that as a hint, and found this implementation:
From that, I was able to construct an answer to your question, and then googled the relevant documentation as well.