feat: serve pastes
This commit is contained in:
parent
00fa4a7c8c
commit
7af4be12ff
2 changed files with 6 additions and 21 deletions
|
|
@ -28,7 +28,7 @@ bool lander_get_entry(event_loop_conn *conn) {
|
|||
http_loop_ctx *ctx = conn->ctx;
|
||||
|
||||
const char *key = &ctx->req.path[ctx->req.regex_groups[1].rm_so];
|
||||
size_t key_len =
|
||||
int key_len =
|
||||
ctx->req.regex_groups[1].rm_eo - ctx->req.regex_groups[1].rm_so;
|
||||
|
||||
Entry *entry;
|
||||
|
|
@ -39,6 +39,11 @@ bool lander_get_entry(event_loop_conn *conn) {
|
|||
} else if (entry->type == Redirect) {
|
||||
ctx->res.type = http_moved_permanently;
|
||||
http_loop_res_add_header(ctx, http_header_location, entry->string, false);
|
||||
} else if (entry->type == Paste) {
|
||||
char fname[8 + key_len];
|
||||
sprintf(fname, "pastes/%.*s", key_len, key);
|
||||
|
||||
http_loop_res_set_body_file(ctx, fname);
|
||||
}
|
||||
|
||||
conn->state = event_loop_conn_state_res;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue