File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -117,12 +117,16 @@ impl Request {
117
117
118
118
/// Returns the result as an `Option` if it exists, otherwise `None`.
119
119
///
120
- /// The option wraps a pointer to a [`ngx_http_upstream_t`] upstream server object.
120
+ /// The option wraps an ngx_http_upstream_t instance, it will be none when the underlying NGINX request
121
+ /// does not have a pointer to a [`ngx_http_upstream_t`] upstream structure.
121
122
///
122
123
/// [`ngx_http_upstream_t`]: is best described in
123
124
/// https://nginx.org/en/docs/dev/development_guide.html#http_request
124
125
/// https://nginx.org/en/docs/dev/development_guide.html#http_load_balancing
125
126
pub fn upstream ( & self ) -> Option < * mut ngx_http_upstream_t > {
127
+ if self . 0 . upstream . is_null ( ) {
128
+ return None ;
129
+ }
126
130
Some ( self . 0 . upstream )
127
131
}
128
132
Original file line number Diff line number Diff line change 2
2
///
3
3
/// Initializes the upstream 'get', 'free', and 'session' callbacks and gives the module writer an
4
4
/// opportunity to set custom data.
5
+ ///
6
+ /// This macro will define the NGINX callback type:
7
+ /// `typedef ngx_int_t (*ngx_http_upstream_init_peer_pt)(ngx_http_request_t *r, ngx_http_upstream_srv_conf_t *us)`,
8
+ /// we keep this macro name in-sync with its underlying NGINX type, this callback is required to
9
+ /// initialize your peer.
10
+ ///
5
11
/// Load Balancing: <https://nginx.org/en/docs/dev/development_guide.html#http_load_balancing>
6
12
#[ macro_export]
7
- macro_rules! http_upstream_peer_init {
13
+ macro_rules! http_upstream_init_peer_pt {
8
14
( $name: ident, $handler: expr ) => {
9
15
#[ no_mangle]
10
16
extern "C" fn $name( r: * mut ngx_http_request_t, us: * mut ngx_http_upstream_srv_conf_t) -> ngx_int_t {
You can’t perform that action at this time.
0 commit comments