diff --git a/examples/async.rs b/examples/async.rs index 2d1522f..34a30ac 100644 --- a/examples/async.rs +++ b/examples/async.rs @@ -5,12 +5,12 @@ use std::sync::Arc; use std::time::Instant; use ngx::core; +use ngx::core::prelude::*; use ngx::ffi::{ - ngx_array_push, ngx_command_t, ngx_conf_t, ngx_cycle, ngx_event_t, ngx_http_core_module, ngx_http_core_run_phases, - ngx_http_handler_pt, ngx_http_module_t, ngx_http_phases_NGX_HTTP_ACCESS_PHASE, ngx_http_request_t, ngx_int_t, - ngx_module_t, ngx_posted_events, ngx_queue_s, ngx_str_t, ngx_uint_t, NGX_CONF_TAKE1, NGX_HTTP_LOC_CONF, - NGX_HTTP_LOC_CONF_OFFSET, NGX_HTTP_MODULE, + ngx_array_push, ngx_http_core_module, ngx_http_core_run_phases, ngx_http_phases_NGX_HTTP_ACCESS_PHASE, + ngx_posted_events, ngx_queue_s, }; +use ngx::http::prelude::*; use ngx::http::{self, HTTPModule, MergeConfigError}; use ngx::{http_request_handler, ngx_log_debug_http, ngx_null_command, ngx_string}; use tokio::runtime::Runtime; diff --git a/examples/awssig.rs b/examples/awssig.rs index bc99f02..b03630c 100644 --- a/examples/awssig.rs +++ b/examples/awssig.rs @@ -3,11 +3,9 @@ use std::ptr::addr_of; use http::HeaderMap; use ngx::core; -use ngx::ffi::{ - ngx_array_push, ngx_command_t, ngx_conf_t, ngx_http_core_module, ngx_http_handler_pt, ngx_http_module_t, - ngx_http_phases_NGX_HTTP_PRECONTENT_PHASE, ngx_int_t, ngx_module_t, ngx_str_t, ngx_uint_t, NGX_CONF_TAKE1, - NGX_HTTP_LOC_CONF, NGX_HTTP_LOC_CONF_OFFSET, NGX_HTTP_MODULE, NGX_HTTP_SRV_CONF, -}; +use ngx::core::prelude::*; +use ngx::ffi::{ngx_array_push, ngx_http_phases_NGX_HTTP_PRECONTENT_PHASE}; +use ngx::http::prelude::*; use ngx::http::*; use ngx::{http_request_handler, ngx_log_debug_http, ngx_null_command, ngx_string}; diff --git a/examples/curl.rs b/examples/curl.rs index 1e4521b..7c01d35 100644 --- a/examples/curl.rs +++ b/examples/curl.rs @@ -2,11 +2,9 @@ use std::ffi::{c_char, c_void}; use std::ptr::addr_of; use ngx::core; -use ngx::ffi::{ - ngx_array_push, ngx_command_t, ngx_conf_t, ngx_http_core_module, ngx_http_handler_pt, ngx_http_module_t, - ngx_http_phases_NGX_HTTP_ACCESS_PHASE, ngx_int_t, ngx_module_t, ngx_str_t, ngx_uint_t, NGX_CONF_TAKE1, - NGX_HTTP_LOC_CONF, NGX_HTTP_LOC_CONF_OFFSET, NGX_HTTP_MODULE, -}; +use ngx::core::prelude::*; +use ngx::ffi::{ngx_array_push, ngx_http_phases_NGX_HTTP_ACCESS_PHASE}; +use ngx::http::prelude::*; use ngx::http::{self, HTTPModule, MergeConfigError}; use ngx::{http_request_handler, ngx_log_debug_http, ngx_null_command, ngx_string}; diff --git a/examples/httporigdst.rs b/examples/httporigdst.rs index 87f7538..cf0b7c2 100644 --- a/examples/httporigdst.rs +++ b/examples/httporigdst.rs @@ -2,11 +2,12 @@ use std::ffi::{c_int, c_void}; use std::ptr::addr_of; use ngx::core; +use ngx::core::prelude::*; use ngx::ffi::{ - in_port_t, ngx_conf_t, ngx_connection_local_sockaddr, ngx_http_add_variable, ngx_http_module_t, - ngx_http_variable_t, ngx_inet_get_port, ngx_int_t, ngx_module_t, ngx_sock_ntop, ngx_str_t, ngx_uint_t, - ngx_variable_value_t, sockaddr, sockaddr_storage, INET_ADDRSTRLEN, NGX_HTTP_MODULE, + in_port_t, ngx_conf_t, ngx_connection_local_sockaddr, ngx_inet_get_port, ngx_sock_ntop, sockaddr, sockaddr_storage, + INET_ADDRSTRLEN, }; +use ngx::http::prelude::*; use ngx::http::{self, HTTPModule}; use ngx::{http_variable_get, ngx_http_null_variable, ngx_log_debug_http, ngx_null_string, ngx_string}; diff --git a/examples/upstream.rs b/examples/upstream.rs index 1b701ac..25806f2 100644 --- a/examples/upstream.rs +++ b/examples/upstream.rs @@ -11,14 +11,14 @@ use std::mem; use std::ptr::addr_of; use std::slice; +use ngx::core::prelude::*; use ngx::core::{Pool, Status}; use ngx::ffi::{ - ngx_atoi, ngx_command_t, ngx_conf_t, ngx_connection_t, ngx_event_free_peer_pt, ngx_event_get_peer_pt, - ngx_http_module_t, ngx_http_upstream_init_peer_pt, ngx_http_upstream_init_pt, ngx_http_upstream_init_round_robin, - ngx_http_upstream_module, ngx_http_upstream_srv_conf_t, ngx_http_upstream_t, ngx_int_t, ngx_module_t, - ngx_peer_connection_t, ngx_str_t, ngx_uint_t, NGX_CONF_NOARGS, NGX_CONF_TAKE1, NGX_CONF_UNSET, NGX_ERROR, - NGX_HTTP_MODULE, NGX_HTTP_SRV_CONF_OFFSET, NGX_HTTP_UPS_CONF, NGX_LOG_EMERG, + ngx_atoi, ngx_event_free_peer_pt, ngx_event_get_peer_pt, ngx_http_upstream_init_peer_pt, ngx_http_upstream_init_pt, + ngx_http_upstream_init_round_robin, ngx_http_upstream_module, ngx_http_upstream_srv_conf_t, ngx_http_upstream_t, + ngx_peer_connection_t, NGX_ERROR, }; +use ngx::http::prelude::*; use ngx::http::{ ngx_http_conf_get_module_srv_conf, ngx_http_conf_upstream_srv_conf_immutable, ngx_http_conf_upstream_srv_conf_mutable, HTTPModule, Merge, MergeConfigError, Request, diff --git a/src/core/mod.rs b/src/core/mod.rs index 07ef434..4531caf 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -1,5 +1,9 @@ mod buffer; mod pool; +/// The prelude module. +/// +/// This module provides common constants and types that are used in NGINX modules. +pub mod prelude; mod status; mod string; diff --git a/src/core/prelude.rs b/src/core/prelude.rs new file mode 100644 index 0000000..38cc276 --- /dev/null +++ b/src/core/prelude.rs @@ -0,0 +1,40 @@ +pub use crate::ffi::ngx_command_t; +pub use crate::ffi::ngx_conf_t; +pub use crate::ffi::ngx_connection_t; +pub use crate::ffi::ngx_event_t; +pub use crate::ffi::ngx_int_t; +pub use crate::ffi::ngx_module_t; +pub use crate::ffi::ngx_str_t; +pub use crate::ffi::ngx_uint_t; +pub use crate::ffi::ngx_variable_value_t; + +pub use crate::ffi::NGX_LOG_ALERT; +pub use crate::ffi::NGX_LOG_CRIT; +pub use crate::ffi::NGX_LOG_DEBUG; +pub use crate::ffi::NGX_LOG_EMERG; +pub use crate::ffi::NGX_LOG_ERR; +pub use crate::ffi::NGX_LOG_INFO; +pub use crate::ffi::NGX_LOG_NOTICE; +pub use crate::ffi::NGX_LOG_WARN; + +pub use crate::ffi::NGX_ANY_CONF; +pub use crate::ffi::NGX_CONF_1MORE; +pub use crate::ffi::NGX_CONF_2MORE; +pub use crate::ffi::NGX_CONF_ANY; +pub use crate::ffi::NGX_CONF_ARGS_NUMBER; +pub use crate::ffi::NGX_CONF_BLOCK; +pub use crate::ffi::NGX_CONF_FLAG; +pub use crate::ffi::NGX_CONF_NOARGS; +pub use crate::ffi::NGX_CONF_TAKE1; +pub use crate::ffi::NGX_CONF_TAKE2; +pub use crate::ffi::NGX_CONF_TAKE3; +pub use crate::ffi::NGX_CONF_TAKE4; +pub use crate::ffi::NGX_CONF_TAKE5; +pub use crate::ffi::NGX_CONF_TAKE6; +pub use crate::ffi::NGX_CONF_TAKE7; +pub use crate::ffi::NGX_CONF_UNSET; +pub use crate::ffi::NGX_DIRECT_CONF; +pub use crate::ffi::NGX_MAIN_CONF; + +pub use crate::ffi::ngx_cycle; +pub use crate::ffi::ngx_posted_events; diff --git a/src/http/mod.rs b/src/http/mod.rs index 00c329a..b273588 100644 --- a/src/http/mod.rs +++ b/src/http/mod.rs @@ -1,5 +1,9 @@ mod conf; mod module; +/// The prelude module. +/// +/// This module provides common constants and types that are used in NGINX http modules. +pub mod prelude; mod request; mod status; mod upstream; diff --git a/src/http/prelude.rs b/src/http/prelude.rs new file mode 100644 index 0000000..40d7f7f --- /dev/null +++ b/src/http/prelude.rs @@ -0,0 +1,23 @@ +pub use crate::ffi::ngx_http_handler_pt; +pub use crate::ffi::ngx_http_module_t; +pub use crate::ffi::ngx_http_request_t; +pub use crate::ffi::ngx_http_variable_t; +pub use crate::ffi::ngx_http_variable_value_t; + +pub use crate::ffi::NGX_HTTP_MODULE; + +pub use crate::ffi::NGX_HTTP_LIF_CONF; +pub use crate::ffi::NGX_HTTP_LMT_CONF; +pub use crate::ffi::NGX_HTTP_LOC_CONF; +pub use crate::ffi::NGX_HTTP_MAIN_CONF; +pub use crate::ffi::NGX_HTTP_SIF_CONF; +pub use crate::ffi::NGX_HTTP_SRV_CONF; +pub use crate::ffi::NGX_HTTP_UPS_CONF; + +pub use crate::ffi::NGX_HTTP_LOC_CONF_OFFSET; +pub use crate::ffi::NGX_HTTP_MAIN_CONF_OFFSET; +pub use crate::ffi::NGX_HTTP_SRV_CONF_OFFSET; + +pub use crate::ffi::ngx_http_core_module; + +pub use crate::ffi::ngx_http_add_variable;