feat(routing): make path segments easily accessible from request struct
This commit is contained in:
parent
fbd41f7e4e
commit
3ae1b62dd0
6 changed files with 105 additions and 65 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "lnm/http/req.h"
|
||||
#include "lnm/log.h"
|
||||
#include "lnm/loop.h"
|
||||
#include "lnm/http/loop.h"
|
||||
|
|
@ -16,8 +17,9 @@ void ctx_free(void *c_ctx) {}
|
|||
lnm_http_step_err print_step(lnm_http_conn *conn) {
|
||||
lnm_http_loop_ctx *ctx = conn->ctx;
|
||||
|
||||
const lnm_http_route_match_segment *seg = lnm_http_route_match_get(&ctx->match, "key");
|
||||
lnm_linfo("main", "key: %.*s", seg->len, ctx->req.buf.s + ctx->req.path.o + seg->start);
|
||||
const char *key;
|
||||
size_t key_len = lnm_http_req_route_segment(&key, &ctx->req, "key") ;
|
||||
lnm_linfo("main", "key: %.*s", key_len, key);
|
||||
return lnm_http_step_err_done;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue