Example #1
0
        public void DoFilter(IConfigRequest request, IConfigResponse response, IConfigFilterChain filterChain)
        {
            if (request != null)
            {
                var raw_content = request.GetParameter(Nacos.V2.Config.ConfigConstants.CONTENT);

                // 部分配置加密后的 content
                var content = ReplaceJsonNode((string)raw_content, true);

                // after encrypt the content, don't forget to update the request!!!
                request.PutParameter(Nacos.V2.Config.ConfigConstants.ENCRYPTED_DATA_KEY, "");
                request.PutParameter(Nacos.V2.Config.ConfigConstants.CONTENT, content);
            }

            if (response != null)
            {
                var resp_content          = response.GetParameter(Nacos.V2.Config.ConfigConstants.CONTENT);
                var resp_encryptedDataKey = response.GetParameter(Nacos.V2.Config.ConfigConstants.ENCRYPTED_DATA_KEY);

                // nacos 2.0.2 still do not return the encryptedDataKey yet
                // but we can use a const key here.
                // after nacos server return the encryptedDataKey, we can keep one dataid with one encryptedDataKey
                var encryptedDataKey = (resp_encryptedDataKey == null || string.IsNullOrWhiteSpace((string)resp_encryptedDataKey)) ? string.Empty : (string)resp_encryptedDataKey;

                var content = ReplaceJsonNode((string)resp_content, false);
                response.PutParameter(Nacos.V2.Config.ConfigConstants.CONTENT, content);
            }
        }
Example #2
0
 public void DoFilter(IConfigRequest request, IConfigResponse response)
 {
     if (_currentPosition != _additionalFilters.Count)
     {
         _currentPosition++;
         var nextFilter = _additionalFilters[_currentPosition - 1];
         nextFilter.DoFilter(request, response, this);
     }
 }
Example #3
0
 public void DoFilter(IConfigRequest request, IConfigResponse response)
 {
     if (this.currentPosition != this.additionalFilters.Count)
     {
         this.currentPosition++;
         IConfigFilter nextFilter = this.additionalFilters[this.currentPosition - 1];
         nextFilter.DoFilter(request, response, this);
     }
 }
Example #4
0
 public void DoFilter(IConfigRequest request, IConfigResponse response)
 {
     new VirtualFilterChain(this.filters).DoFilter(request, response);
 }