Servent and status other than 200 - Haskell

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

Magnus Therning

I feel a little silly about asking this, but how do I get servant to create success responses with status other than 200?

Georgi Lyubenov // googleson78

you can specify it by directly using the Verb type

Georgi Lyubenov // googleson78

instead of the synonyms for it, which are more commonly used, such as GET

Georgi Lyubenov // googleson78

and if you want to be able to return more than one success status code for a given endpoint you can either hack it using throwErr, or more appropriately, you can use the new UVerb machinery (disclaimer: I haven't tried it out)

Magnus Therning

Thanks, that was the information I never saw mentioned in any tutorial or example I've found!

Magnus Therning

It does raise one question though. When thinking about it I mentally connect the verb with the request and the status with the response. I'm probably influenced by the various HTTP libraries I've used across multiple languages. AFAICS there's no obvious relationship between verb and status in the protocol at all.

So what's the reason for connecting the verb and the status in this way? Is there a philosophical/logical reasoning behind it?