membphis commented on code in PR #12179: URL: https://github.com/apache/apisix/pull/12179#discussion_r2062932031
########## apisix/admin/init.lua: ########## @@ -453,18 +463,34 @@ local uri_route = { } +local standalone_uri_route = { + http_head_route, + { + paths = [[/apisix/admin/configs]], + methods = {"GET", "PUT"}, + handler = standalone_run, + }, +} + + function _M.init_worker() local local_conf = core.config.local_conf() if not local_conf.apisix or not local_conf.apisix.enable_admin then return end - router = route.new(uri_route) + local is_yaml_config_provider = local_conf.deployment.config_provider == "yaml" + + router = route.new(is_yaml_config_provider and standalone_uri_route or uri_route) Review Comment: code style: for me, this way is much easier to understand ```lua if is_yaml_config_provider then router = route.new(standalone_uri_route) else router = route.new(uri_route) end ########## t/pnpm-lock.yaml: ########## @@ -0,0 +1,2904 @@ +# +# 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. +# + +lockfileVersion: '9.0' Review Comment: do we have to add this file? ########## t/admin/standalone.spec.ts: ########## @@ -0,0 +1,232 @@ +/* + * 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. + */ + +import axios from "axios"; +import YAML from "yaml"; + +const config1 = { + routes: [ + { + id: "r1", + uri: "/r1", + upstream: { + nodes: { "127.0.0.1:1980": 1 }, + type: "roundrobin", + }, + plugins: { "proxy-rewrite": { uri: "/hello" } }, + }, + ], +}; +const config2 = { + routes: [ + { + id: "r2", + uri: "/r2", + upstream: { + nodes: { "127.0.0.1:1980": 1 }, + type: "roundrobin", + }, + plugins: { "proxy-rewrite": { uri: "/hello" } }, + }, + ], +}; +const clientConfig = { + baseURL: "http://localhost:1984", + headers: { + "X-API-KEY": "edd1c9f034335f136f87ad84b625c8f1", + }, +}; + +describe("Admin - Standalone", () => { Review Comment: this is a new way to write test cases we can use `test::nginx`, got the same result, all right? ########## t/package.json: ########## @@ -0,0 +1,16 @@ +{ Review Comment: how about `t/ts/package.json`? move all of the `ts` related files to folder `t/ts` -- 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: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org