summaryrefslogtreecommitdiff
path: root/snac.c
diff options
context:
space:
mode:
authorLouis Brauer <louis@openbooking.ch>2024-05-27 16:25:20 +0200
committerLouis Brauer <louis@openbooking.ch>2024-05-27 19:01:04 +0200
commit26fbda787d0d5c8ba9259f79f4d2f937bd6c8ead (patch)
tree8615eda88a882eb4959abf707a693374f22d9752 /snac.c
parent637a88fb0f20aa5aad2dcd66ec7ec7b39f7af0e2 (diff)
Translate status codes to canonical status texts
Use those in HTTP responses instead of "OK"/"ERROR". Apps like Tokodon show only the status text in unexpected responses.
Diffstat (limited to 'snac.c')
-rw-r--r--snac.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/snac.c b/snac.c
index 5ba98e1..0df8691 100644
--- a/snac.c
+++ b/snac.c
@@ -170,3 +170,15 @@ int check_password(const char *uid, const char *passwd, const char *hash)
return ret;
}
+
+
+const char *http_status_text(int status)
+/* translate status codes to canonical status texts */
+{
+ switch (status) {
+#define HTTP_STATUS(code, name, text) case HTTP_STATUS_ ## name: return #text;
+#include "http_codes.h"
+#undef HTTP_STATUS
+ default: return "Unknown";
+ }
+}