66-- (the "License"); you may not use this file except in compliance with
77-- the License. You may obtain a copy of the License at
88--
9- -- http://www.apache.org/licenses/LICENSE-2.0
9+ -- http://www.apache.org/licenses/LICENSE-2.0
1010--
1111-- Unless required by applicable law or agreed to in writing, software
1212-- distributed under the License is distributed on an "AS IS" BASIS,
1616--
1717local util = require (" apisix.plugins.grpc-transcode.util" )
1818local grpc_proto = require (" apisix.plugins.grpc-transcode.proto" )
19- local core = require (" apisix.core" )
20- local pb = require (" pb" )
21- local ngx = ngx
22- local string = string
19+ local core = require (" apisix.core" )
20+ local pb = require (" pb" )
21+ local ngx = ngx
22+ local string = string
2323local ngx_decode_base64 = ngx .decode_base64
24- local ipairs = ipairs
25- local pcall = pcall
24+ local ipairs = ipairs
25+ local pcall = pcall
2626local type = type
2727local pairs = pairs
2828local setmetatable = setmetatable
@@ -48,11 +48,11 @@ local function fetch_proto_array_names(proto_obj)
4848 return names
4949end
5050
51- local function set_default_array (tab ,array_names )
51+ local function set_default_array (tab , array_names )
5252 if type (tab ) ~= " table" then
5353 return false
5454 end
55- for k , v in pairs (tab ) do
55+ for k , v in pairs (tab ) do
5656 if type (v ) == " table" then
5757 if array_names [k ] == 1 then
5858 setmetatable (v ,core .json .array_mt )
@@ -101,7 +101,7 @@ local function handle_error_response(status_detail_type, proto)
101101 pb .state (pb_old_state )
102102 if not ok then
103103 err_msg = " failed to call pb.decode to decode details in "
104- .. " grpc-status-details-bin"
104+ .. " grpc-status-details-bin"
105105 ngx .arg [1 ] = err_msg
106106 return err_msg .. " , err: " .. err_or_value
107107 end
@@ -151,7 +151,7 @@ return function(ctx, proto, service, method, pb_option, show_status_in_body, sta
151151 local m = util .find_method (proto , service , method )
152152 if not m then
153153 return false , " 2.Undefined service method: " .. service .. " /" .. method
154- .. " end."
154+ .. " end."
155155 end
156156
157157 if not ngx .req .get_headers ()[" X-Grpc-Web" ] then
@@ -170,8 +170,8 @@ return function(ctx, proto, service, method, pb_option, show_status_in_body, sta
170170 return err_msg
171171 end
172172
173- local array_names = fetch_proto_array_names ( proto )
174- set_default_array (decoded ,array_names )
173+ local array_names = fetch_proto_array_names ( proto )
174+ set_default_array (decoded , array_names )
175175
176176 local response , err = core .json .encode (decoded )
177177 if not response then
0 commit comments