|
1 | 1 | use std::ffi::CStr; |
2 | | -use std::ptr::addr_of_mut; |
3 | 2 |
|
4 | 3 | use ngx::ffi::{ngx_conf_t, ngx_str_t}; |
5 | | -use ngx::http::{HttpMainConf, HttpModuleSkel}; |
| 4 | +use ngx::http::HttpMainConf; |
6 | 5 | use ngx::module::{ |
7 | 6 | CommandArgFlag, CommandArgFlagSet, CommandCallRule, CommandContextFlag, CommandContextFlagSet, CommandError, |
8 | 7 | }; |
9 | | -use ngx::{arg_flags, context_flags, ngx_string}; |
| 8 | +use ngx::{arg_flags, context_flags, exhibit_modules, ngx_string}; |
10 | 9 | use ngx::{ |
11 | 10 | http::{DefaultInit, DefaultMerge, HttpModule, NgxHttpModule, NgxHttpModuleCommands}, |
12 | 11 | module::{Command, NgxModuleCommandsBuilder}, |
13 | 12 | }; |
14 | 13 |
|
15 | 14 | #[cfg(static_ref_mut)] |
16 | 15 | use ngx::{exhibit_modules, http::NgxHttpModuleCommandsRefMut, util::StaticRefMut}; |
| 16 | +#[cfg(not(static_ref_mut))] |
| 17 | +use std::ptr::addr_of_mut; |
| 18 | + |
| 19 | +#[cfg(not(static_ref_mut))] |
| 20 | +use ngx::{ |
| 21 | + http::HttpModuleSkel, |
| 22 | + module::{NgxModule, NgxModuleCtx}, |
| 23 | + ngx_modules, |
| 24 | +}; |
| 25 | +#[cfg(not(static_ref_mut))] |
| 26 | +use std::ptr::addr_of; |
17 | 27 |
|
18 | 28 | #[cfg(all(static_ref_mut, feature = "export-modules"))] |
19 | 29 | exhibit_modules!(HttpModuleSkel<FooBarHttpModule>); |
20 | 30 |
|
| 31 | +#[cfg(all(not(static_ref_mut), feature = "export-modules"))] |
| 32 | +exhibit_modules!(HttpModuleSkel<FooBarHttpModule> => &mut FOO_BAR_HTTP_MODULE); |
| 33 | + |
| 34 | +#[cfg(not(static_ref_mut))] |
| 35 | +static mut FOO_BAR_HTTP_MODULE: NgxModule<HttpModuleSkel<FooBarHttpModule>> = unsafe { |
| 36 | + NgxModule::new_from_ptr( |
| 37 | + addr_of!(FOO_BAR_HTTP_MODULE_CTX), |
| 38 | + addr_of!(FOO_BAR_HTTP_MODULE_COMMANDS), |
| 39 | + ) |
| 40 | +}; |
| 41 | +#[cfg(not(static_ref_mut))] |
| 42 | +static mut FOO_BAR_HTTP_MODULE_CTX: NgxModuleCtx<HttpModuleSkel<FooBarHttpModule>> = |
| 43 | + unsafe { NgxModuleCtx::from_raw() }; |
| 44 | + |
| 45 | +#[cfg(not(static_ref_mut))] |
| 46 | +static mut FOO_BAR_HTTP_MODULE_COMMANDS: NgxHttpModuleCommands<FooBarHttpModule, { 1 + 1 }> = |
| 47 | + NgxModuleCommandsBuilder::new().add::<FooBarCommand>().build(); |
| 48 | + |
21 | 49 | struct FooBarHttpModule; |
22 | 50 | impl HttpModule for FooBarHttpModule { |
23 | 51 | #[cfg(static_ref_mut)] |
|
0 commit comments