2024-01-31 08:38:13 +01:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "lnm/log.h"
|
|
|
|
#include "lnm/http/loop.h"
|
|
|
|
|
|
|
|
lnm_err ctx_init(void **c_ctx, void *gctx) {
|
|
|
|
*c_ctx = NULL;
|
|
|
|
|
|
|
|
return lnm_err_ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ctx_reset(void *c_ctx) {}
|
|
|
|
void ctx_free(void *c_ctx) {}
|
|
|
|
|
|
|
|
lnm_http_step_err slow_step(lnm_http_conn *conn) {
|
|
|
|
sleep(1);
|
|
|
|
|
|
|
|
return lnm_http_step_err_done;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
lnm_http_loop *hl;
|
|
|
|
lnm_http_step *step = NULL;
|
|
|
|
lnm_http_route *route;
|
|
|
|
|
|
|
|
lnm_http_loop_init(&hl, NULL, ctx_init,
|
|
|
|
ctx_reset,
|
|
|
|
ctx_free);
|
|
|
|
|
2024-02-14 12:43:58 +01:00
|
|
|
lnm_http_step_append(&step, slow_step, true);
|
2024-01-31 08:38:13 +01:00
|
|
|
lnm_http_route_init_literal(&route, lnm_http_method_get, "/", step);
|
|
|
|
lnm_http_loop_route_add(hl, route);
|
|
|
|
|
|
|
|
lnm_log_init_global();
|
|
|
|
lnm_log_register_stdout(lnm_log_level_debug);
|
|
|
|
|
2024-02-14 12:43:58 +01:00
|
|
|
printf("res = %i\n", lnm_http_loop_run(hl, 8080, 1, 2));
|
2024-01-31 08:38:13 +01:00
|
|
|
}
|