Drery commented on a change in pull request #5940: URL: https://github.com/apache/apisix/pull/5940#discussion_r776207099
########## File path: apisix/plugins/mocking.lua ########## @@ -0,0 +1,148 @@ +-- +-- 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 ngx = ngx +local plugin_name = "mocking" + +local schema = { + type = "object", + properties = { + response_schema = { type = "object" } + }, + required = { "response_schema" } +} + +local _M = { + version = 0.1, + priority = 9900, + name = plugin_name, + schema = schema, +} + +function _M.check_schema(conf) + local ok, err = core.schema.check(schema, conf) + if not ok then + return false, err + end + + return true, nil +end + +function _M.access(conf) + local output = gen_object(conf.response_schema) + ngx.header["Content-Type"] = "application/json" Review comment: > hi, @Drery thanks for your contribution. Mock has many applications in front-end and back-end development and client troubleshooting scenarios. this is a good idea. However, I checked this PR. Its current completion rate is relatively low and only supports responses in a single data format.I think the simulation plug-in should support custom responses, custom data formats, custom headers, custom status codes, and custom timeouts to meet the basic simulation requirements. thank for your sugguest. i commit the PR just want to know how do you think about this idea. if you approve this idea, i will enrich this plugin to support more scenes. -- 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]
