summary refs log tree commit diff
path: root/server.h
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-07-09 20:39:38 -0400
committerJune McEnroe <june@causal.agency>2020-07-09 20:39:38 -0400
commitec20355dfdcf27f43a7341d225edddd605a3ba7c (patch)
tree5ee822c7d27a800bb8e717af120f8ee7d42c1344 /server.h
parentImplement very basic events listing (diff)
downloadscooper-ec20355dfdcf27f43a7341d225edddd605a3ba7c.tar.gz
scooper-ec20355dfdcf27f43a7341d225edddd605a3ba7c.zip
Add before param in redirect
Diffstat (limited to '')
-rw-r--r--server.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/server.h b/server.h
index 0e77f7c..b1a22ee 100644
--- a/server.h
+++ b/server.h
@@ -121,6 +121,14 @@ httpHead(struct kreq *req, enum khttp http, enum kmime mime) {
 		|| khttp_head(req, kresps[KRESP_CONTENT_TYPE], "%s", kmimetypes[mime]);
 }
 
+static inline enum kcgi_err
+httpRedirect(struct kreq *req, const char *url) {
+	return httpHead(req, KHTTP_302, KMIME_TEXT_PLAIN)
+		|| khttp_head(req, kresps[KRESP_LOCATION], "%s", url)
+		|| khttp_body(req)
+		|| khttp_printf(req, "%s\n", url);
+}
+
 static inline enum kcgi_err httpFail(struct kreq *req, enum khttp http) {
 	return httpHead(req, http, KMIME_TEXT_PLAIN)
 		|| khttp_body(req)