diff --git a/apisix/plugins/echo-copy.lua b/apisix/plugins/echo-copy.lua deleted file mode 100644 index 8d71880ccf7e2..0000000000000 --- a/apisix/plugins/echo-copy.lua +++ /dev/null @@ -1,134 +0,0 @@ --- --- 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 balancer = require("ngx.balancer") -local ngx = ngx - - -local schema = { - type = "object", - properties = { - before_body = {type = "string"}, - body = {type = "string"}, - after_body = {type = "string"}, - status_code = {type = "integer"}, - headers = { - type = "object", - minProperties = 1, - }, - request_uri = {type = "string"}, - redirect_uri = {type = "string"} - } -} - -local plugin_name = "echo-plugin" - -local _M = { - version = 0.1, - priority = 100, - name = plugin_name, - schema = schema, -} - - -function _M.check_schema(conf) - return core.schema.check(schema, conf) -end - -function _M.init(conf, ctx) - core.log.warn("plugin init phase start you can initialize the lua_shared_dict shm storage at this phase") - local dict = ngx.shared.dogs; - - if dict then - core.log.warn("plugin init phase removing cache for dogs shm storage") - dict.flush_all(dict) - dict.flush_expired(dict) - end - - core.log.warn("plugin init phase you can preload lua modules during this phase") -end - - -function _M.body_filter(conf, ctx) - core.log.warn("plugin body filter phase, before body overide", core.json.encode(conf.before_body)) - core.log.warn("plugin body filter phase, response body to use for the overide", core.json.encode(conf.body)) - core.log.warn("plugin body filter phase, after response overide", core.json.encode(conf.after_body)) -end - -function _M.header_filter(conf, ctx) - if conf.status_code then - core.log.warn("plugin header filter phase, set the new status code ", core.json.encode(conf.status_code)) - end - - if conf.headers then - local field_cnt = #conf.headers - for i = 1, field_cnt, 2 do - core.log.warn("plugin header filter phase, header to add", core.json.encode(conf.headers_arr[i])) - core.log.warn("plugin header filter phase, corresponding value", core.json.encode(conf.headers_arr[i+1])) - end - end -end - -function _M.access(conf, ctx) - local res = ngx.location.capture("/hello") - if res.status == ngx.HTTP_OK then - core.log.warn("plugin acess phase, The end point is accessible") - end - - if res.status == ngx.HTTP_FORBIDDEN then - core.log.warn("plugin acess phase, The endpoint is not accessible try with authentication headers") - end - - if(res.status_code == ngx.HTTP_INTERNAL_SERVER_ERROR) then - core.log.warn("plugin acess phase, Internal server error please check you're configurations") - end -end - -function _M.rewrite(conf, ctx) - core.log.warn("plugin rewrite phase, current location uri", core.json.encode(conf.request_uri)) - core.log.warn("In case of spam, black list or unauthorized access or even in a need of redirect we can use this phase to" - +"redirect to new URI") - core.log.warn("plugin rewrite phase, we can redirect the request in this location to a new uri", - core.json.encode(conf.redirect_uri)) -end - -function _M.balancer(conf, ctx) - core.log.warn("plugin balancer phase, conf: ", core.json.encode(conf)) - - if not conf.ip then - return - end - -- NOTE: update `ctx.balancer_name` is important, APISIX will skip other - -- balancer handler. - ctx.balancer_name = plugin_name - - local ok, err = balancer.set_current_peer(conf.ip, conf.port) - if not ok then - core.log.error("failed to set server peer: ", err) - return core.response.exit(502) - end -end - -function _M.log(conf, ctx) - core.log.warn("plugin log phase you can perform the task from the data that gathered during the other phases") -end - -function _M.echo_simple(conf, ctx) - return 200, {message = "echo sample"} -end - -return _M