tokers commented on a change in pull request #5331:
URL: https://github.com/apache/apisix/pull/5331#discussion_r736061924
##########
File path: apisix/plugins/grpc-transcode/util.lua
##########
@@ -14,31 +14,43 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
-local core = require("apisix.core")
-local json = core.json
-local pb = require("pb")
-local ngx = ngx
-local pairs = pairs
-local ipairs = ipairs
-local string = string
-local tonumber = tonumber
-local type = type
+local core = require("apisix.core")
+local proto_fake_file =
require("apisix..plugins.grpc-transcode.proto").proto_fake_file
+local json = core.json
+local pb = require("pb")
+local ngx = ngx
+local ipairs = ipairs
+local string = string
+local tonumber = tonumber
+local type = type
local _M = {version = 0.1}
function _M.find_method(protos, service, method)
- for k, loaded in pairs(protos) do
- if type(loaded) == 'table' then
- local package = loaded.package
- for _, s in ipairs(loaded.service or {}) do
- if package .. "." .. s.name == service then
- for _, m in ipairs(s.method) do
- if m.name == method then
- return m
- end
- end
+ local loaded = protos[proto_fake_file]
+ if loaded == nil or type(loaded) ~= "table" then
+ return nil
+ end
+
+ local pkg, svc_name
+ for w in service:gmatch('([^.]+)') do
Review comment:
Why not just use `ngx.re.match`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]