How to make the handlers type module like ngx_stab_status #165
-
Hi, I would like to implement some module with this. Thus anyone who can make some module as known as The details of the handler type module is here. We can see Especially, We don't have any clue to implement setting the handler function like |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
With the current git master, the C code for setting the content handler translates to the following Rust: use ngx::http::HttpModuleLocationConf;
http_request_handler!(example_handler, |_r: &mut ngx::http::Request| {
ngx::http::HTTPStatus::FORBIDDEN.into()
});
extern "C" fn example_set_handler(
cf: *mut ngx_conf_t,
_cmd: *mut ngx_command_t,
_conf: *mut c_void,
) -> *mut c_char {
// SAFETY: configuration handlers always receive valid `cf`.
let cf = unsafe { &mut *cf };
let clcf = ngx::http::NgxHttpCoreModule::location_conf_mut(cf).expect("core location conf");
clcf.handler = Some(example_handler);
ngx::core::NGX_CONF_OK
} Configuration access traits are a recent addition though, so code for 0.4.1 would look closer to the C variant. |
Beta Was this translation helpful? Give feedback.
With the current git master, the C code for setting the content handler translates to the following Rust:
Configuration access traits a…