-
Notifications
You must be signed in to change notification settings - Fork 39
/
ngx_http_rds_json_filter_module.h
96 lines (62 loc) · 2.37 KB
/
ngx_http_rds_json_filter_module.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* Copyright (C) agentzh
*/
#ifndef NGX_HTTP_RDS_JSON_FILTER_MODULE_H
#define NGX_HTTP_RDS_JSON_FILTER_MODULE_H
#include "ngx_http_rds.h"
#include <ngx_core.h>
#include <ngx_http.h>
#include <nginx.h>
#ifndef NGX_HTTP_RESET_CONTENT
#define NGX_HTTP_RESET_CONTENT 205
#endif
extern ngx_module_t ngx_http_rds_json_filter_module;
extern ngx_http_output_header_filter_pt ngx_http_rds_json_next_header_filter;
extern ngx_http_output_body_filter_pt ngx_http_rds_json_next_body_filter;
typedef enum {
json_format_normal,
json_format_compact,
json_format_pretty /* TODO */
} ngx_http_rds_json_format_t;
typedef struct {
ngx_flag_t enabled;
ngx_uint_t format;
ngx_str_t content_type;
ngx_str_t root;
size_t buf_size;
/* for rds_json_ret */
ngx_str_t errcode;
ngx_http_complex_value_t *errstr;
} ngx_http_rds_json_conf_t;
typedef enum {
state_expect_header,
state_expect_col,
state_expect_row,
state_expect_field,
state_expect_more_field_data,
state_done
} ngx_http_rds_json_state_t;
typedef struct {
ngx_http_rds_json_state_t state;
ngx_str_t *col_name;
ngx_uint_t col_count;
ngx_uint_t cur_col;
ngx_http_rds_column_t *cols;
size_t row;
uint32_t field_offset;
uint32_t field_total;
ngx_buf_tag_t tag;
ngx_chain_t *out;
ngx_chain_t **last_out;
ngx_chain_t *busy_bufs;
ngx_chain_t *free_bufs;
ngx_buf_t *out_buf;
ngx_buf_t cached;
ngx_buf_t postponed;
size_t avail_out;
uint32_t field_data_rest;
ngx_flag_t header_sent:1;
ngx_flag_t seen_stream_end:1;
ngx_flag_t generated_col_names:1;
} ngx_http_rds_json_ctx_t;
#endif /* NGX_HTTP_RDS_JSON_FILTER_MODULE_H */