nxt_http_variables.c (1563:d32bc428f46b) nxt_http_variables.c (1587:0bef0a02c8c4)
1
2/*
3 * Copyright (C) NGINX, Inc.
4 */
5
6#include <nxt_router.h>
7#include <nxt_http.h>
8
9
10static nxt_int_t nxt_http_var_method(nxt_task_t *task, nxt_var_query_t *query,
11 nxt_str_t *str, void *ctx);
12static nxt_int_t nxt_http_var_uri(nxt_task_t *task, nxt_var_query_t *query,
13 nxt_str_t *str, void *ctx);
1
2/*
3 * Copyright (C) NGINX, Inc.
4 */
5
6#include <nxt_router.h>
7#include <nxt_http.h>
8
9
10static nxt_int_t nxt_http_var_method(nxt_task_t *task, nxt_var_query_t *query,
11 nxt_str_t *str, void *ctx);
12static nxt_int_t nxt_http_var_uri(nxt_task_t *task, nxt_var_query_t *query,
13 nxt_str_t *str, void *ctx);
14static nxt_int_t nxt_http_var_host(nxt_task_t *task, nxt_var_query_t *query,
15 nxt_str_t *str, void *ctx);
14
15
16static nxt_var_decl_t nxt_http_vars[] = {
17 { nxt_string("method"),
18 &nxt_http_var_method,
19 0 },
20
21 { nxt_string("uri"),
22 &nxt_http_var_uri,
23 0 },
16
17
18static nxt_var_decl_t nxt_http_vars[] = {
19 { nxt_string("method"),
20 &nxt_http_var_method,
21 0 },
22
23 { nxt_string("uri"),
24 &nxt_http_var_uri,
25 0 },
26
27 { nxt_string("host"),
28 &nxt_http_var_host,
29 0 },
24};
25
26
27nxt_int_t
28nxt_http_register_variables(void)
29{
30 return nxt_var_register(nxt_http_vars, nxt_nitems(nxt_http_vars));
31}

--- 20 unchanged lines hidden (view full) ---

52 nxt_http_request_t *r;
53
54 r = ctx;
55
56 *str = *r->path;
57
58 return NXT_OK;
59}
30};
31
32
33nxt_int_t
34nxt_http_register_variables(void)
35{
36 return nxt_var_register(nxt_http_vars, nxt_nitems(nxt_http_vars));
37}

--- 20 unchanged lines hidden (view full) ---

58 nxt_http_request_t *r;
59
60 r = ctx;
61
62 *str = *r->path;
63
64 return NXT_OK;
65}
66
67
68static nxt_int_t
69nxt_http_var_host(nxt_task_t *task, nxt_var_query_t *query, nxt_str_t *str,
70 void *ctx)
71{
72 nxt_http_request_t *r;
73
74 r = ctx;
75
76 *str = r->host;
77
78 return NXT_OK;
79}