refactor(lander): clean up code a bit

This commit is contained in:
Jef Roosens 2023-11-12 14:48:55 +01:00
parent c026e13c44
commit 64af94ce7a
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
9 changed files with 103 additions and 457 deletions

View file

@ -7,7 +7,6 @@
#include "http/req.h"
#include "http/res.h"
#include "http/types.h"
#include "trie.h"
// Max amount of steps a route can use
#define HTTP_LOOP_MAX_STEPS 17

View file

@ -5,17 +5,15 @@
#include "lsm/store.h"
extern http_route lander_routes[6];
extern const char lander_key_charset[];
typedef struct lander_gctx {
const char *data_dir;
Trie *trie;
lsm_store *store;
} lander_gctx;
typedef struct lander_ctx {
lsm_entry_handle *entry;
uint64_t remaining_data;
} lander_ctx;
typedef enum lander_attr_type : uint8_t {
@ -24,6 +22,14 @@ typedef enum lander_attr_type : uint8_t {
lander_attr_type_url = 2,
} lander_attr_type;
typedef struct {
char *header;
lander_attr_type attr_type;
http_header header_type;
} header_to_attr;
extern header_to_attr header_to_attrs[];
typedef enum lander_entry_type : uint8_t {
lander_entry_type_redirect = 0,
lander_entry_type_paste = 1,
@ -46,21 +52,19 @@ bool lander_post_redirect(event_loop_conn *conn);
bool lander_post_paste(event_loop_conn *conn);
bool lander_post_paste_lsm(event_loop_conn *conn);
bool lander_post_paste(event_loop_conn *conn);
bool lander_post_redirect_lsm(event_loop_conn *conn);
bool lander_post_redirect(event_loop_conn *conn);
bool lander_stream_body_to_entry(event_loop_conn *conn);
bool lander_stream_body_to_client(event_loop_conn *conn);
bool lander_get_entry_lsm(event_loop_conn *conn);
bool lander_post_redirect_body_to_attr(event_loop_conn *conn);
bool lander_remove_entry(event_loop_conn *conn);
bool lander_post_file_lsm(event_loop_conn *conn);
bool lander_post_file(event_loop_conn *conn);
/**
* Parse any custom headers and add them as attributes to the context's LSM