File tree Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -32,3 +32,7 @@ def exit_process():
3232 log .debug ('exit_process: %r' , mod )
3333 mod .exit_process ()
3434 _modules .clear ()
35+
36+
37+ def post_read ():
38+ log .critical ('post read hook!' )
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ from .nginx_core cimport ngx_log_error
1010
1111from . import hooks
1212
13+
1314cdef public ngx_int_t nginxpy_init_process(ngx_cycle_t * cycle):
1415 ngx_log_error(NGX_LOG_DEBUG, cycle.log, 0 ,
1516 b' Starting init_process.' )
@@ -29,6 +30,7 @@ cdef public ngx_int_t nginxpy_init_process(ngx_cycle_t *cycle):
2930 b' Finished init_process.' )
3031 return NGX_OK
3132
33+
3234cdef public void nginxpy_exit_process(ngx_cycle_t * cycle):
3335 ngx_log_error(NGX_LOG_DEBUG, cycle.log, 0 ,
3436 b' Starting exit_process.' )
@@ -46,6 +48,11 @@ cdef public void nginxpy_exit_process(ngx_cycle_t *cycle):
4648 ngx_log_error(NGX_LOG_DEBUG, cycle.log, 0 ,
4749 b' Finished exit_process.' )
4850
51+
52+ cdef public void nginxpy_post_read():
53+ hooks.post_read()
54+
55+
4956include " log.pyx"
5057include " cycle.pyx"
5158include " asyncio/loop.pyx"
Original file line number Diff line number Diff line change 77
88static ngx_int_t ngx_python_init_process (ngx_cycle_t * cycle );
99static void ngx_python_exit_process (ngx_cycle_t * cycle );
10+ static ngx_int_t ngx_python_postconfiguration (ngx_conf_t * cf );
11+ static ngx_int_t ngx_python_post_read (ngx_http_request_t * r );
1012
1113static wchar_t * python_exec = NULL ;
1214
1315
1416static ngx_http_module_t ngx_python_module_ctx = {
1517 NULL , /* preconfiguration */
16- NULL , /* postconfiguration */
18+ ngx_python_postconfiguration , /* postconfiguration */
1719
1820 NULL , /* create main configuration */
1921 NULL , /* init main configuration */
@@ -79,3 +81,25 @@ ngx_python_exit_process(ngx_cycle_t *cycle) {
7981 "Failed to finalize Python!" );
8082 }
8183}
84+
85+ static ngx_int_t
86+ ngx_python_postconfiguration (ngx_conf_t * cf ) {
87+ ngx_http_handler_pt * h ;
88+ ngx_http_core_main_conf_t * cmcf ;
89+
90+ cmcf = ngx_http_conf_get_module_main_conf (cf , ngx_http_core_module );
91+
92+ h = ngx_array_push (& cmcf -> phases [NGX_HTTP_POST_READ_PHASE ].handlers );
93+ if (h == NULL ) {
94+ return NGX_ERROR ;
95+ }
96+ * h = ngx_python_post_read ;
97+
98+ return NGX_OK ;
99+ }
100+
101+ static ngx_int_t
102+ ngx_python_post_read (ngx_http_request_t * r ) {
103+ nginxpy_post_read ();
104+ return NGX_OK ;
105+ }
You can’t perform that action at this time.
0 commit comments