feat(lander): re-add authentication using LNM
All checks were successful
ci/woodpecker/push/build Pipeline was successful
All checks were successful
ci/woodpecker/push/build Pipeline was successful
This commit is contained in:
parent
8dc8ef8e2d
commit
1a7686003c
4 changed files with 41 additions and 6 deletions
17
src/main.c
17
src/main.c
|
|
@ -7,13 +7,14 @@
|
|||
#include "lander.h"
|
||||
#include "log.h"
|
||||
|
||||
lnm_http_loop *loop_init(lander_gctx *gctx) {
|
||||
lnm_http_loop *loop_init(lander_gctx *gctx, const char *api_key) {
|
||||
lnm_http_loop *hl;
|
||||
lnm_http_step *step = NULL;
|
||||
lnm_http_route *route;
|
||||
lnm_http_loop_init(&hl, gctx, lander_ctx_init,
|
||||
(lnm_http_ctx_reset_fn)lander_ctx_reset,
|
||||
(lnm_http_ctx_free_fn)lander_ctx_free);
|
||||
lnm_http_loop_set_api_key(hl, api_key);
|
||||
|
||||
lnm_http_step_init(&step, lander_get_index);
|
||||
lnm_http_route_init_literal(&route, lnm_http_method_get, "/", step);
|
||||
|
|
@ -23,28 +24,32 @@ lnm_http_loop *loop_init(lander_gctx *gctx) {
|
|||
lnm_http_route_init_regex(&route, lnm_http_method_get, "^/([^/]+)$", 1, step);
|
||||
lnm_http_loop_route_add(hl, route);
|
||||
|
||||
lnm_http_step_init(&step, lander_post_redirect);
|
||||
lnm_http_step_init(&step, lnm_http_loop_step_auth);
|
||||
lnm_http_route_init_regex(&route, lnm_http_method_post, "^/s(l?)/([^/]*)$", 2,
|
||||
step);
|
||||
lnm_http_step_append(&step, step, lander_post_redirect);
|
||||
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, lander_post_paste);
|
||||
lnm_http_step_init(&step, lnm_http_loop_step_auth);
|
||||
lnm_http_route_init_regex(&route, lnm_http_method_post, "^/p(l?)/([^/]*)$", 2,
|
||||
step);
|
||||
lnm_http_step_append(&step, step, lander_post_paste);
|
||||
lnm_http_step_append(&step, step, lander_stream_body_to_entry);
|
||||
lnm_http_loop_route_add(hl, route);
|
||||
|
||||
lnm_http_step_init(&step, lander_post_file);
|
||||
lnm_http_step_init(&step, lnm_http_loop_step_auth);
|
||||
lnm_http_route_init_regex(&route, lnm_http_method_post, "^/f(l?)/([^/]*)$", 2,
|
||||
step);
|
||||
lnm_http_step_append(&step, step, lander_post_file);
|
||||
lnm_http_step_append(&step, step, lander_stream_body_to_entry);
|
||||
lnm_http_loop_route_add(hl, route);
|
||||
|
||||
lnm_http_step_init(&step, lander_remove_entry);
|
||||
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;
|
||||
|
|
@ -89,7 +94,7 @@ int main() {
|
|||
}
|
||||
|
||||
info("Store loaded containing %lu entries", lsm_store_size(c_gctx->store));
|
||||
lnm_http_loop *hl = loop_init(c_gctx);
|
||||
lnm_http_loop *hl = loop_init(c_gctx, api_key);
|
||||
lnm_http_loop_run(hl, port);
|
||||
|
||||
/* http_loop *hl = http_loop_init( */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue