refactor(lander): make index code work with new lnm
ci/woodpecker/push/build Pipeline was successful Details

ltm
Jef Roosens 2024-03-09 21:11:21 +01:00
parent 452e936956
commit 4089570293
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
3 changed files with 24 additions and 17 deletions

View File

@ -68,6 +68,8 @@ lnm_http_step_err lander_post_file_secure(lnm_http_conn *conn);
lnm_http_step_err lander_post_index(lnm_http_conn *conn);
lnm_http_step_err lander_post_index_secure(lnm_http_conn *conn);
/**
* Store the requested header as an attribute, if it's present.
*/

View File

@ -148,11 +148,11 @@ lnm_http_step_err lander_post_file_secure(lnm_http_conn *conn) {
return __lander_post_file(conn, true);
}
lnm_http_step_err lander_post_index(lnm_http_conn *conn) {
static lnm_http_step_err __lander_post_index(lnm_http_conn *conn, bool secure) {
lnm_http_loop_ctx *ctx = conn->ctx;
lander_ctx *c_ctx = ctx->c;
if (!lander_insert_entry(ctx)) {
if (!lander_insert_entry(ctx, secure)) {
return lnm_http_step_err_res;
}
@ -165,3 +165,11 @@ lnm_http_step_err lander_post_index(lnm_http_conn *conn) {
return lnm_http_step_err_done;
}
lnm_http_step_err lander_post_index(lnm_http_conn *conn) {
return __lander_post_index(conn, false);
}
lnm_http_step_err lander_post_index_secure(lnm_http_conn *conn) {
return __lander_post_index(conn, true);
}

View File

@ -72,7 +72,6 @@ lnm_http_loop *loop_init(lander_gctx *gctx, const char *api_key) {
lnm_http_route_step_append(route, lnm_http_loop_step_body_to_buf, false);
lnm_http_route_step_append(route, lander_post_redirect_body_to_attr, false);
<<<<<<< HEAD
lnm_http_router_add(&route, router, lnm_http_method_post, "/sl/");
lnm_http_route_step_append(route, lnm_http_loop_step_auth, false);
lnm_http_route_step_append(route, lander_post_redirect_secure, false);
@ -115,22 +114,20 @@ lnm_http_loop *loop_init(lander_gctx *gctx, const char *api_key) {
lnm_http_route_step_append(route, lander_post_file, false);
lnm_http_route_step_append(route, lander_stream_body_to_entry, false);
lnm_http_router_add(&route, router, lnm_http_method_post, "/i/");
lnm_http_route_step_append(route, lnm_http_loop_step_auth, false);
lnm_http_route_step_append(route, lander_post_index, false);
lnm_http_router_add(&route, router, lnm_http_method_post, "/il/");
lnm_http_route_step_append(route, lnm_http_loop_step_auth, false);
lnm_http_route_step_append(route, lander_post_index_secure, false);
lnm_http_router_add(&route, router, lnm_http_method_post, "/i/:key");
lnm_http_route_step_append(route, lnm_http_loop_step_auth, false);
lnm_http_route_step_append(route, lander_post_index, false);
lnm_http_loop_router_set(hl, router);
lnm_http_step_init(&step, lnm_http_loop_step_auth);
lnm_http_route_init_regex(&route, lnm_http_method_post, "^/i(l?)/([^/]+)$", 2,
step);
lnm_http_step_append(&step, step, lander_post_index);
/* lnm_http_step_append(&step, step, lnm_http_loop_step_body_to_buf); */
/* lnm_http_step_append(&step, step, lander_post_redirect_body_to_attr); */
lnm_http_loop_route_add(hl, route);
lnm_http_step_init(&step, lnm_http_loop_step_auth);
lnm_http_route_init_regex(&route, lnm_http_method_delete, "^/([^/]+)$", 1,
step);
lnm_http_step_append(&step, step, lander_remove_entry);
lnm_http_loop_route_add(hl, route);
return hl;
}