Created
January 21, 2024 13:20
-
-
Save patryk4815/ed29ec27104cab72157250588a62e58a to your computer and use it in GitHub Desktop.
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
#include <ngx_config.h> | |
#include <ngx_core.h> | |
#include <ngx_string.h> | |
#include <ngx_http.h> | |
#include <ngx_event_openssl.h> | |
extern ngx_module_t ngx_foo_module; | |
typedef struct { | |
ngx_flag_t enable; | |
} ngx_foo_conf_t; | |
static ngx_command_t ngx_foo_commands[] = { | |
{ | |
ngx_string("foo_enable"), | |
NGX_HTTP_SRV_CONF | NGX_CONF_FLAG, | |
ngx_conf_set_flag_slot, | |
NGX_HTTP_SRV_CONF_OFFSET, | |
offsetof(ngx_foo_conf_t, enable), | |
NULL | |
}, | |
ngx_null_command | |
}; | |
static ngx_http_module_t ngx_foo_module_ctx = { | |
ngx_foo_variables, /* preconfiguration */ | |
NULL, /* postconfiguration */ | |
NULL, /* create main configuration */ | |
NULL, /* init main configuration */ | |
ngx_foo_create_srv_conf, /* create server configuration */ | |
ngx_foo_merge_srv_conf, /* merge server configuration */ | |
NULL, /* create location configuration */ | |
NULL /* merge location configuration */ | |
}; | |
ngx_module_t ngx_foo_module = { | |
NGX_MODULE_V1, | |
&ngx_foo_module_ctx, /* module context */ | |
ngx_foo_commands, /* module directives */ | |
NGX_HTTP_MODULE, /* module type */ | |
NULL, /* init master */ | |
ngx_foo_init_module, /* init module */ | |
NULL, /* init process */ | |
NULL, /* init thread */ | |
NULL, /* exit thread */ | |
NULL, /* exit process */ | |
NULL, /* exit master */ | |
NGX_MODULE_V1_PADDING | |
}; | |
static void * | |
ngx_foo_create_srv_conf(ngx_conf_t *cf) { | |
ngx_foo_conf_t *conf = ngx_pcalloc(cf->pool, sizeof(ngx_foo_conf_t)); | |
if (conf == NULL) { | |
return NGX_CONF_ERROR; | |
} | |
conf->enable = NGX_CONF_UNSET; | |
return conf; | |
} | |
static char * | |
ngx_foo_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) { | |
ngx_foo_conf_t *prev = parent; | |
ngx_foo_conf_t *conf = child; | |
ngx_conf_merge_value(conf->enable, prev->enable, 0); | |
return NGX_CONF_OK; | |
} | |
static ngx_int_t | |
ngx_foo_variables(ngx_conf_t *cf) { | |
return NGX_OK; | |
} | |
static ngx_int_t | |
ngx_foo_init_module(ngx_cycle_t *cycle) { | |
return NGX_OK; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment