aboutsummaryrefslogtreecommitdiffstats
path: root/ui-shared.c
diff options
context:
space:
mode:
authorJohn Keeping <john@keeping.me.uk>2015-08-14 12:47:01 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2015-08-14 15:46:51 +0200
commitaec1204a54e3baa12c76db75c2f67696def05eb0 (patch)
tree313974d5bc7e8c26178f266f632d993cca2b883b /ui-shared.c
parentaa12084f9835783abbd1f1e4609f8de05e73cec4 (diff)
ui-shared: add cgit_print_error_page() function
This will allow us to generate error responses with the correct HTTP response code without needing all of the layout boilerplate. Signed-off-by: John Keeping <john@keeping.me.uk>
Diffstat (limited to '')
-rw-r--r--ui-shared.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 36fcb21..06dd0a8 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -788,6 +788,20 @@ void cgit_print_docend(void)
html("</body>\n</html>\n");
}
+void cgit_print_error_page(int code, const char *msg, const char *fmt, ...)
+{
+ va_list ap;
+ ctx.page.status = code;
+ ctx.page.statusmsg = msg;
+ cgit_print_http_headers();
+ cgit_print_docstart();
+ cgit_print_pageheader();
+ va_start(ap, fmt);
+ cgit_vprint_error(fmt, ap);
+ va_end(ap);
+ cgit_print_docend();
+}
+
static void add_clone_urls(void (*fn)(const char *), char *txt, char *suffix)
{
struct strbuf **url_list = strbuf_split_str(txt, ' ', 0);