-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Supporting changes for upstream example module.
- functions to get mut and const module context from the ngx_http_upstream_srv_conf_t - Request from trait - Request upstream getter - Request peer init macro
- Loading branch information
Matthew Yacobucci
committed
Aug 31, 2023
1 parent
7972ae7
commit d48bcf3
Showing
4 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/// Define a static upstream peer initializer | ||
/// | ||
/// Initializes the upstream 'get', 'free', and 'session' callbacks and gives the module writer an | ||
/// opportunity to set custom data. | ||
/// Load Balancing: <https://nginx.org/en/docs/dev/development_guide.html#http_load_balancing> | ||
#[macro_export] | ||
macro_rules! http_upstream_peer_init { | ||
( $name: ident, $handler: expr ) => { | ||
#[no_mangle] | ||
extern "C" fn $name(r: *mut ngx_http_request_t, us: *mut ngx_http_upstream_srv_conf_t) -> ngx_int_t { | ||
let status: Status = $handler(unsafe { &mut Request::from_ngx_http_request(r) }, us); | ||
status.0 | ||
} | ||
}; | ||
} |