File tree Expand file tree Collapse file tree 2 files changed +13
-13
lines changed Expand file tree Collapse file tree 2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -6,17 +6,6 @@ local pcall   = pcall
66local  _M  =  {version  =  0.9 }
77
88
9- local  function  require_serializer (serializer_name )
10-     if  serializer_name  then 
11-         local  ok , module  =  pcall (require , " resty.etcd.serializers."  ..  serializer_name )
12-         if  ok  then 
13-             return  module 
14-         end 
15-     end 
16- 
17-     return  require (" resty.etcd.serializers.json" 
18- end 
19- 
209function  _M .new (opts )
2110    opts  =  opts  or  {}
2211    if  not  typeof .table (opts ) then 
@@ -33,7 +22,7 @@ function _M.new(opts)
3322    opts .ttl   =  opts .ttl  or  - 1 
3423
3524    local  serializer_name  =  typeof .string (opts .serializer ) and  opts .serializer 
36-     opts .serializer  =  require_serializer ( serializer_name ) 
25+     opts .serializer  =  serializer_name 
3726    opts .api_prefix  =  " /v3" 
3827
3928    return  etcdv3 .new (opts )
Original file line number Diff line number Diff line change @@ -265,6 +265,17 @@ local function serialize_and_encode_base64(serialize_fn, data)
265265    return  encode_base64 (data )
266266end 
267267
268+ local  function  require_serializer (serializer_name )
269+     if  serializer_name  then 
270+         local  ok , module  =  pcall (require , " resty.etcd.serializers."  ..  serializer_name )
271+         if  ok  then 
272+             return  module 
273+         end 
274+     end 
275+ 
276+     return  require (" resty.etcd.serializers.json" 
277+ end 
278+ 
268279
269280function  _M .new (opts )
270281    local  timeout     =  opts .timeout 
@@ -278,7 +289,7 @@ function _M.new(opts)
278289    if  ssl_verify  ==  nil  then 
279290        ssl_verify  =  true 
280291    end 
281-     local  serializer  =  opts .serializer 
292+     local  serializer  =  require_serializer ( opts .serializer ) 
282293    local  extra_headers  =  opts .extra_headers 
283294    local  sni         =  opts .sni 
284295    local  unix_socket_proxy  =  opts .unix_socket_proxy 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments