Skip to content

Commit 598c8c3

Browse files
committed
feat: expose minimal sufficient set of symbols via ::prelude::*
1 parent a542225 commit 598c8c3

File tree

9 files changed

+90
-22
lines changed

9 files changed

+90
-22
lines changed

Diff for: examples/async.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ use std::sync::Arc;
55
use std::time::Instant;
66

77
use ngx::core;
8+
use ngx::core::prelude::*;
89
use ngx::ffi::{
9-
ngx_array_push, ngx_command_t, ngx_conf_t, ngx_cycle, ngx_event_t, ngx_http_core_module, ngx_http_core_run_phases,
10-
ngx_http_handler_pt, ngx_http_module_t, ngx_http_phases_NGX_HTTP_ACCESS_PHASE, ngx_http_request_t, ngx_int_t,
11-
ngx_module_t, ngx_posted_events, ngx_queue_s, ngx_str_t, ngx_uint_t, NGX_CONF_TAKE1, NGX_HTTP_LOC_CONF,
12-
NGX_HTTP_LOC_CONF_OFFSET, NGX_HTTP_MODULE,
10+
ngx_array_push, ngx_http_core_module, ngx_http_core_run_phases, ngx_http_phases_NGX_HTTP_ACCESS_PHASE,
11+
ngx_posted_events, ngx_queue_s,
1312
};
13+
use ngx::http::prelude::*;
1414
use ngx::http::{self, HTTPModule, MergeConfigError};
1515
use ngx::{http_request_handler, ngx_log_debug_http, ngx_null_command, ngx_string};
1616
use tokio::runtime::Runtime;

Diff for: examples/awssig.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ use std::ptr::addr_of;
33

44
use http::HeaderMap;
55
use ngx::core;
6-
use ngx::ffi::{
7-
ngx_array_push, ngx_command_t, ngx_conf_t, ngx_http_core_module, ngx_http_handler_pt, ngx_http_module_t,
8-
ngx_http_phases_NGX_HTTP_PRECONTENT_PHASE, ngx_int_t, ngx_module_t, ngx_str_t, ngx_uint_t, NGX_CONF_TAKE1,
9-
NGX_HTTP_LOC_CONF, NGX_HTTP_LOC_CONF_OFFSET, NGX_HTTP_MODULE, NGX_HTTP_SRV_CONF,
10-
};
6+
use ngx::core::prelude::*;
7+
use ngx::ffi::{ngx_array_push, ngx_http_phases_NGX_HTTP_PRECONTENT_PHASE};
8+
use ngx::http::prelude::*;
119
use ngx::http::*;
1210
use ngx::{http_request_handler, ngx_log_debug_http, ngx_null_command, ngx_string};
1311

Diff for: examples/curl.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ use std::ffi::{c_char, c_void};
22
use std::ptr::addr_of;
33

44
use ngx::core;
5-
use ngx::ffi::{
6-
ngx_array_push, ngx_command_t, ngx_conf_t, ngx_http_core_module, ngx_http_handler_pt, ngx_http_module_t,
7-
ngx_http_phases_NGX_HTTP_ACCESS_PHASE, ngx_int_t, ngx_module_t, ngx_str_t, ngx_uint_t, NGX_CONF_TAKE1,
8-
NGX_HTTP_LOC_CONF, NGX_HTTP_LOC_CONF_OFFSET, NGX_HTTP_MODULE,
9-
};
5+
use ngx::core::prelude::*;
6+
use ngx::ffi::{ngx_array_push, ngx_http_phases_NGX_HTTP_ACCESS_PHASE};
7+
use ngx::http::prelude::*;
108
use ngx::http::{self, HTTPModule, MergeConfigError};
119
use ngx::{http_request_handler, ngx_log_debug_http, ngx_null_command, ngx_string};
1210

Diff for: examples/httporigdst.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ use std::ffi::{c_int, c_void};
22
use std::ptr::addr_of;
33

44
use ngx::core;
5+
use ngx::core::prelude::*;
56
use ngx::ffi::{
6-
in_port_t, ngx_conf_t, ngx_connection_local_sockaddr, ngx_http_add_variable, ngx_http_module_t,
7-
ngx_http_variable_t, ngx_inet_get_port, ngx_int_t, ngx_module_t, ngx_sock_ntop, ngx_str_t, ngx_variable_value_t,
8-
sockaddr, sockaddr_storage, INET_ADDRSTRLEN, NGX_HTTP_MODULE,
7+
in_port_t, ngx_conf_t, ngx_connection_local_sockaddr, ngx_inet_get_port, ngx_sock_ntop, sockaddr, sockaddr_storage,
8+
INET_ADDRSTRLEN,
99
};
10+
use ngx::http::prelude::*;
1011
use ngx::http::{self, HTTPModule};
1112
use ngx::{http_variable_get, ngx_http_null_variable, ngx_log_debug_http, ngx_null_string, ngx_string};
1213

Diff for: examples/upstream.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ use std::mem;
1111
use std::ptr::addr_of;
1212
use std::slice;
1313

14+
use ngx::core::prelude::*;
1415
use ngx::core::{Pool, Status};
1516
use ngx::ffi::{
16-
ngx_atoi, ngx_command_t, ngx_conf_t, ngx_connection_t, ngx_event_free_peer_pt, ngx_event_get_peer_pt,
17-
ngx_http_module_t, ngx_http_upstream_init_peer_pt, ngx_http_upstream_init_pt, ngx_http_upstream_init_round_robin,
18-
ngx_http_upstream_module, ngx_http_upstream_srv_conf_t, ngx_http_upstream_t, ngx_int_t, ngx_module_t,
19-
ngx_peer_connection_t, ngx_str_t, ngx_uint_t, NGX_CONF_NOARGS, NGX_CONF_TAKE1, NGX_CONF_UNSET, NGX_ERROR,
20-
NGX_HTTP_MODULE, NGX_HTTP_SRV_CONF_OFFSET, NGX_HTTP_UPS_CONF, NGX_LOG_EMERG,
17+
ngx_atoi, ngx_event_free_peer_pt, ngx_event_get_peer_pt, ngx_http_upstream_init_peer_pt, ngx_http_upstream_init_pt,
18+
ngx_http_upstream_init_round_robin, ngx_http_upstream_module, ngx_http_upstream_srv_conf_t, ngx_http_upstream_t,
19+
ngx_peer_connection_t, NGX_ERROR,
2120
};
21+
use ngx::http::prelude::*;
2222
use ngx::http::{
2323
ngx_http_conf_get_module_srv_conf, ngx_http_conf_upstream_srv_conf_immutable,
2424
ngx_http_conf_upstream_srv_conf_mutable, HTTPModule, Merge, MergeConfigError, Request,

Diff for: src/core/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
mod buffer;
22
mod pool;
3+
/// The prelude module.
4+
///
5+
/// This module provides common constants and types that are used in NGINX modules.
6+
pub mod prelude;
37
mod status;
48
mod string;
59

Diff for: src/core/prelude.rs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
pub use crate::ffi::ngx_command_t;
2+
pub use crate::ffi::ngx_conf_t;
3+
pub use crate::ffi::ngx_connection_t;
4+
pub use crate::ffi::ngx_event_t;
5+
pub use crate::ffi::ngx_int_t;
6+
pub use crate::ffi::ngx_module_t;
7+
pub use crate::ffi::ngx_str_t;
8+
pub use crate::ffi::ngx_uint_t;
9+
pub use crate::ffi::ngx_variable_value_t;
10+
11+
pub use crate::ffi::NGX_LOG_ALERT;
12+
pub use crate::ffi::NGX_LOG_CRIT;
13+
pub use crate::ffi::NGX_LOG_DEBUG;
14+
pub use crate::ffi::NGX_LOG_EMERG;
15+
pub use crate::ffi::NGX_LOG_ERR;
16+
pub use crate::ffi::NGX_LOG_INFO;
17+
pub use crate::ffi::NGX_LOG_NOTICE;
18+
pub use crate::ffi::NGX_LOG_WARN;
19+
20+
pub use crate::ffi::NGX_ANY_CONF;
21+
pub use crate::ffi::NGX_CONF_1MORE;
22+
pub use crate::ffi::NGX_CONF_2MORE;
23+
pub use crate::ffi::NGX_CONF_ANY;
24+
pub use crate::ffi::NGX_CONF_ARGS_NUMBER;
25+
pub use crate::ffi::NGX_CONF_BLOCK;
26+
pub use crate::ffi::NGX_CONF_FLAG;
27+
pub use crate::ffi::NGX_CONF_NOARGS;
28+
pub use crate::ffi::NGX_CONF_TAKE1;
29+
pub use crate::ffi::NGX_CONF_TAKE2;
30+
pub use crate::ffi::NGX_CONF_TAKE3;
31+
pub use crate::ffi::NGX_CONF_TAKE4;
32+
pub use crate::ffi::NGX_CONF_TAKE5;
33+
pub use crate::ffi::NGX_CONF_TAKE6;
34+
pub use crate::ffi::NGX_CONF_TAKE7;
35+
pub use crate::ffi::NGX_CONF_UNSET;
36+
pub use crate::ffi::NGX_DIRECT_CONF;
37+
pub use crate::ffi::NGX_MAIN_CONF;
38+
39+
pub use crate::ffi::ngx_cycle;
40+
pub use crate::ffi::ngx_posted_events;

Diff for: src/http/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
mod conf;
22
mod module;
3+
/// The prelude module.
4+
///
5+
/// This module provides common constants and types that are used in NGINX http modules.
6+
pub mod prelude;
37
mod request;
48
mod status;
59
mod upstream;

Diff for: src/http/prelude.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
pub use crate::ffi::ngx_http_handler_pt;
2+
pub use crate::ffi::ngx_http_module_t;
3+
pub use crate::ffi::ngx_http_request_t;
4+
pub use crate::ffi::ngx_http_variable_t;
5+
pub use crate::ffi::ngx_http_variable_value_t;
6+
7+
pub use crate::ffi::NGX_HTTP_MODULE;
8+
9+
pub use crate::ffi::NGX_HTTP_LIF_CONF;
10+
pub use crate::ffi::NGX_HTTP_LMT_CONF;
11+
pub use crate::ffi::NGX_HTTP_LOC_CONF;
12+
pub use crate::ffi::NGX_HTTP_MAIN_CONF;
13+
pub use crate::ffi::NGX_HTTP_SIF_CONF;
14+
pub use crate::ffi::NGX_HTTP_SRV_CONF;
15+
pub use crate::ffi::NGX_HTTP_UPS_CONF;
16+
17+
pub use crate::ffi::NGX_HTTP_LOC_CONF_OFFSET;
18+
pub use crate::ffi::NGX_HTTP_MAIN_CONF_OFFSET;
19+
pub use crate::ffi::NGX_HTTP_SRV_CONF_OFFSET;
20+
21+
pub use crate::ffi::ngx_http_core_module;
22+
23+
pub use crate::ffi::ngx_http_add_variable;

0 commit comments

Comments
 (0)