Mercurial > hg > ngx_http_auth_request_module
diff ngx_http_auth_request_module.c @ 1:dfc5ae42367a
Auth request: support switching off.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 26 Feb 2010 21:21:22 +0300 |
parents | 436da5355bd5 |
children | 35f0ee7a3c28 |
line wrap: on
line diff
--- a/ngx_http_auth_request_module.c +++ b/ngx_http_auth_request_module.c @@ -27,15 +27,17 @@ static void *ngx_http_auth_request_creat static char *ngx_http_auth_request_merge_conf(ngx_conf_t *cf, void *parent, void *child); static ngx_int_t ngx_http_auth_request_init(ngx_conf_t *cf); +static char *ngx_http_auth_request(ngx_conf_t *cf, ngx_command_t *cmd, + void *conf); static ngx_command_t ngx_http_auth_request_commands[] = { { ngx_string("auth_request"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, - ngx_conf_set_str_slot, + ngx_http_auth_request, NGX_HTTP_LOC_CONF_OFFSET, - offsetof(ngx_http_auth_request_conf_t, uri), + 0, NULL }, ngx_null_command @@ -231,3 +233,29 @@ ngx_http_auth_request_init(ngx_conf_t *c return NGX_OK; } + + +static char * +ngx_http_auth_request(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) +{ + ngx_http_auth_request_conf_t *arcf = conf; + + ngx_str_t *value; + + if (arcf->uri.data != NULL) { + return "is duplicate"; + } + + value = cf->args->elts; + + if (ngx_strcmp(value[1].data, "off") == 0) { + arcf->uri.len = 0; + arcf->uri.data = (u_char *) ""; + + return NGX_CONF_OK; + } + + arcf->uri = value[1]; + + return NGX_CONF_OK; +}