feat: add server level command and merge (#3)

Signed-off-by: stonex <1479765922@qq.com>
diff --git a/NginxCasbinConf.hpp b/NginxCasbinConf.hpp
index 8a80756..e6089e2 100644
--- a/NginxCasbinConf.hpp
+++ b/NginxCasbinConf.hpp
@@ -35,7 +35,7 @@
     };
 
     // Must init the variable
-    ngx_flag_t enabled =  (ngx_flag_t)NgxUnsetValue::get();
+    ngx_flag_t enabled = (ngx_flag_t)NgxUnsetValue::get();
     ngx_str_t adopter = ngx_null_string;
     ngx_str_t model_path = ngx_null_string;
     ngx_str_t policy_path = ngx_null_string;
@@ -50,18 +50,21 @@
         return ret;
     }
 
-    // TODO: merge http/server level config 
-    // static char* merge(ngx_conf_t *cf, void *parent, void *child)
-    // {
-    //     boost::ignore_unused(cf);
+    static char* merge(ngx_conf_t *cf, void *parent, void *child)
+    {
 
-    //     auto prev = reinterpret_cast<this_type*>(parent);
-    //     auto conf = reinterpret_cast<this_type*>(child);
+        auto prev = reinterpret_cast<this_type*>(parent);
+        auto conf = reinterpret_cast<this_type*>(child);
 
-    //     NgxValue::merge(conf->enabled, prev->enabled, 0);
+        // if location has this this_command, use location option
+        // else use outer loation 
+        // either both, do nothing
+        if (conf->enabled == (ngx_flag_t)NgxUnsetValue::get()) {
+            memcpy(conf, prev, sizeof(this_type));
+        }
 
-    //     return NGX_CONF_OK;
-    // }
+        return NGX_CONF_OK;
+    }
 
     // static ADOPTER_TYPE get_adopter_type (ngx_str_t& adopter_str) {
     //     auto str = NgxString(adopter_str).str();
diff --git a/NginxCasbinHandler.hpp b/NginxCasbinHandler.hpp
index a8c05e3..bd25250 100644
--- a/NginxCasbinHandler.hpp
+++ b/NginxCasbinHandler.hpp
@@ -64,7 +64,6 @@
 
             if (mcf->enabled == (long int)1) {
 
-                // TODO 
                 // 1. build enforcer by different model and policy
                 // 2. find key in url by enforcer model
                 // 3. get ans from enforcer 
diff --git a/NginxCasbinInit.hpp b/NginxCasbinInit.hpp
index 9d95646..4938d6d 100644
--- a/NginxCasbinInit.hpp
+++ b/NginxCasbinInit.hpp
@@ -115,7 +115,7 @@
             static ngx_command_t n[] = {
                 {
                     ngx_string("casbin"),
-                    NGX_HTTP_LOC_CONF | NGX_CONF_FLAG | NGX_CONF_TAKE1,
+                    NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_FLAG | NGX_CONF_TAKE1,
                     ngx_set_command_call_back,
                     NGX_HTTP_LOC_CONF_OFFSET,
                     offsetof(NgxCasbinConf, enabled),
@@ -123,7 +123,7 @@
                 },
                 {
                     ngx_string("casbin_adopter"),
-                    NGX_HTTP_SRV_CONF| NGX_HTTP_LOC_CONF | NGX_CONF_TAKE3,
+                    NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_TAKE3,
                     casbin_adopter_parser,
                     NGX_HTTP_LOC_CONF_OFFSET,
                     offsetof(NgxCasbinConf, adopter),
@@ -145,7 +145,7 @@
                 nullptr,
 
                 &conf_type::create,
-                nullptr
+                &conf_type::merge,
             };
 
             return &c;