membphis commented on a change in pull request #1388: feature: add api 
aggregate plugin.
URL: https://github.com/apache/incubator-apisix/pull/1388#discussion_r408556983
 
 

 ##########
 File path: apisix/plugins/api-aggregate.lua
 ##########
 @@ -0,0 +1,144 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+local core   = require("apisix.core")
+local http   = require("resty.http")
+local ngx    = ngx
+local ipairs = ipairs
+local pairs  = pairs
+local type   = type
+
+local plugin_name = "api-aggregate"
+
+local schema = {
+    type = "object",
+    properties = {
+    }
+}
+
+local _M = {
+    version = 0.1,
+    priority = 4010,
+    name = plugin_name,
+    schema = schema
+}
+
+local function check_input(data)
+    if not data.pipeline then
+        return 400, {message = "missing 'pipeline' in input"}
+    end
+    local type_timeout = type(data.timeout)
+    if type_timeout ~= "number" and type_timeout ~= "nil" then
+        return 400, {message = "'timeout' should be number"}
+    end
+    if not data.timeout or data.timeout == 0 then
+        data.timeout = 30000
+    end
+end
+
+local function set_base_header(data)
+    if not data.headers then
+        return
+    end
+
+    for i,req in ipairs(data.pipeline) do
+        if not req.headers then
+            req.headers = data.headers
+        else
+            for k, v in pairs(data.headers) do
+                if not req.headers[k] then
+                    req.headers[k] = v
+                end
+            end
+        end
+    end
+end
+
+local function set_base_query(data)
+    if not data.query then
+        return
+    end
+
+    for i,req in ipairs(data.pipeline) do
+        if not req.query then
+            req.query = data.query
+        else
+            for k, v in pairs(data.query) do
+                if not req.query[k] then
+                    req.query[k] = v
+                end
+            end
+        end
+    end
+end
+
+local function aggregate(service_id)
+    ngx.req.read_body()
+    local req_body = ngx.req.get_body_data()
 
 Review comment:
   "2. the request body has been read into disk temporary files,"
   
   We need to handle the case normally.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to