Search code examples
capache2apache-modules

Apache access the server_rec for a module


I want to get at the value in server_rec.module_config. Does request_rec have any sort of reference to the server_rec? I am not seeing one in the httpd.h file but I could be missing it.

Basically I want to access the configuration file for the module while in my handler and I know I can do that with ap_get_module_config(). However I don't think request_rec.request_config or request_rec.per_dir_config store what I need.

Help is appreciated! And yes I have looked through the Apache guide to making modules (found here).


Solution

  • After more looking around I finally managed to come across it.

    In the request_rec there is a variable called server which is a server_rec*. So to access the config file you would use

    ap_get_module_config(r->server->module_config, &my_module)
    

    where r is the request_rec passed into the handler.