diff options
author | Igor Sysoev <igor@sysoev.ru> | 2019-02-27 16:41:11 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2019-02-27 16:41:11 +0300 |
commit | d4ccaae900f78b13923a9bd9ee7bbaa33c99b18b (patch) | |
tree | 6755a201d8b49f6945a213d76bf40d2b6ea7666d /src/nxt_http.h | |
parent | 95c9bba33bcb1d0e8e9e7c64d2591187ce11bab1 (diff) | |
download | unit-d4ccaae900f78b13923a9bd9ee7bbaa33c99b18b.tar.gz unit-d4ccaae900f78b13923a9bd9ee7bbaa33c99b18b.tar.bz2 |
Initial routing implementation.
Diffstat (limited to 'src/nxt_http.h')
-rw-r--r-- | src/nxt_http.h | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/nxt_http.h b/src/nxt_http.h index af0b2cd6..23c406d3 100644 --- a/src/nxt_http.h +++ b/src/nxt_http.h @@ -21,6 +21,7 @@ typedef enum { NXT_HTTP_NOT_MODIFIED = 304, NXT_HTTP_BAD_REQUEST = 400, + NXT_HTTP_NOT_FOUND = 404, NXT_HTTP_REQUEST_TIMEOUT = 408, NXT_HTTP_LENGTH_REQUIRED = 411, NXT_HTTP_PAYLOAD_TOO_LARGE = 413, @@ -112,6 +113,7 @@ struct nxt_http_request_s { nxt_buf_t *out; const nxt_http_request_state_t *state; + nxt_str_t host; nxt_str_t target; nxt_str_t version; nxt_str_t *method; @@ -124,7 +126,6 @@ struct nxt_http_request_s { nxt_http_field_t *cookie; nxt_http_field_t *referer; nxt_http_field_t *user_agent; - nxt_str_t host; nxt_off_t content_length_n; nxt_sockaddr_t *remote; @@ -136,6 +137,7 @@ struct nxt_http_request_s { nxt_http_status_t status:16; + uint8_t pass_count; /* 8 bits */ uint8_t protocol; /* 2 bits */ uint8_t logged; /* 1 bit */ uint8_t header_sent; /* 1 bit */ @@ -143,6 +145,22 @@ struct nxt_http_request_s { }; +typedef struct nxt_http_route_s nxt_http_route_t; + + +struct nxt_http_pass_s { + nxt_http_pass_t *(*handler)(nxt_task_t *task, + nxt_http_request_t *r, + nxt_http_pass_t *pass); + union { + nxt_http_route_t *route; + nxt_app_t *application; + } u; + + nxt_str_t name; +}; + + typedef void (*nxt_http_proto_body_read_t)(nxt_task_t *task, nxt_http_request_t *r); typedef void (*nxt_http_proto_local_addr_t)(nxt_task_t *task, @@ -184,6 +202,18 @@ nxt_int_t nxt_http_request_field(void *ctx, nxt_http_field_t *field, nxt_int_t nxt_http_request_content_length(void *ctx, nxt_http_field_t *field, uintptr_t data); +nxt_http_routes_t *nxt_http_routes_create(nxt_task_t *task, + nxt_router_temp_conf_t *tmcf, nxt_conf_value_t *routes_conf); +nxt_http_pass_t *nxt_http_pass_create(nxt_task_t *task, + nxt_router_temp_conf_t *tmcf, nxt_str_t *name); +void nxt_http_routes_resolve(nxt_task_t *task, nxt_router_temp_conf_t *tmcf); +nxt_http_pass_t *nxt_http_pass_application(nxt_task_t *task, + nxt_router_temp_conf_t *tmcf, nxt_str_t *name); +void nxt_http_routes_cleanup(nxt_task_t *task, nxt_http_routes_t *routes); +void nxt_http_pass_cleanup(nxt_task_t *task, nxt_http_pass_t *pass); + +nxt_http_pass_t *nxt_http_request_application(nxt_task_t *task, + nxt_http_request_t *r, nxt_http_pass_t *pass); extern nxt_time_string_t nxt_http_date_cache; |