57 lines
1.7 KiB
C
57 lines
1.7 KiB
C
#include <stdio.h>
|
|
|
|
#include "http_loop.h"
|
|
#include "lander.h"
|
|
#include "lsm/store.h"
|
|
|
|
http_route lander_routes[] = {
|
|
{.type = http_route_literal,
|
|
.method = http_get,
|
|
.path = "/",
|
|
.steps = {lander_get_index, NULL},
|
|
.steps_res = {http_loop_step_write_header, http_loop_step_write_body,
|
|
NULL}},
|
|
{
|
|
.type = http_route_regex,
|
|
.method = http_get,
|
|
.path = "^/([^/]+)$",
|
|
.steps = {lander_get_entry_lsm, NULL},
|
|
.steps_res = {http_loop_step_write_header, lander_stream_body_to_client,
|
|
NULL},
|
|
},
|
|
{
|
|
.type = http_route_regex,
|
|
.method = http_post,
|
|
.path = "^/s(l?)/([^/]*)$",
|
|
.steps = {http_loop_step_auth, lander_post_redirect_lsm,
|
|
http_loop_step_body_to_buf, lander_post_redirect_body_to_attr,
|
|
lander_entry_sync, NULL},
|
|
.steps_res = {http_loop_step_write_header, http_loop_step_write_body,
|
|
NULL},
|
|
},
|
|
{.type = http_route_regex,
|
|
.method = http_post,
|
|
.path = "^/p(l?)/([^/]*)$",
|
|
.steps = {http_loop_step_auth, http_loop_step_parse_content_length,
|
|
lander_post_paste_lsm, lander_stream_body_to_entry,
|
|
lander_entry_sync, NULL},
|
|
.steps_res = {http_loop_step_write_header, http_loop_step_write_body,
|
|
NULL}},
|
|
};
|
|
|
|
void *lander_gctx_init() { return calloc(1, sizeof(lander_gctx)); }
|
|
|
|
void *lander_ctx_init() { return calloc(1, sizeof(lander_ctx)); }
|
|
|
|
void lander_ctx_reset(lander_ctx *ctx) {
|
|
if (ctx->entry != NULL) {
|
|
lsm_entry_close(ctx->entry);
|
|
|
|
ctx->entry = NULL;
|
|
}
|
|
|
|
ctx->remaining_data = 0;
|
|
}
|
|
|
|
void lander_ctx_free(lander_ctx *ctx) { free(ctx); }
|