An access environment switching method and system
By automatically matching domain names and configuring authorization, the problem of restarting caused by frequent environment switching during system development is solved, achieving seamless switching and efficient development.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-10
- Publication Date
- 2026-03-17
AI Technical Summary
During system development, frequently switching project environments requires restarting the project, which affects development efficiency.
By obtaining the first access domain name and sequentially determining whether it contains server parameters, a preset specified domain name, and preset key fields, the system automatically matches and switches to the second access domain name using the configuration file. When necessary, it obtains authorization data to configure authorization parameters, thus achieving seamless access.
The project does not need to be restarted during the domain name switch, which improves system development efficiency.
Smart Images

Figure CN116599843B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of web applications, and in particular to a method and system for switching access environments. Background Technology
[0002] The classic model of system development typically includes: development environment, testing environment, pre-production environment, and production environment. The production environment is the system that is officially used. During system development, staff often need to frequently switch between project environments, which often requires restarting the project, affecting system development efficiency. Summary of the Invention
[0003] To improve the efficiency of system development, this application provides a method and system for switching access environments.
[0004] Firstly, this application provides a method for switching access environments, employing the following technical solution:
[0005] A method for switching access environments includes:
[0006] Obtain the first access domain name;
[0007] Determine whether the first access domain contains a server parameter. If so, based on a preset configuration file, switch the first access domain to a second access domain that matches the server parameter; otherwise,
[0008] Then determine whether the first access domain name is a preset specified domain name. If so, based on the configuration file, switch the first access domain name to the second access domain name corresponding to the preset specified domain name; otherwise,
[0009] Then, the preset key fields in the first access domain name are determined, and based on the determination result and the configuration file, the first access domain name is switched to the second access domain name.
[0010] By adopting the above technical solution, after obtaining the first access domain name, it is determined in turn whether the first access domain name contains the server parameter, whether it contains the preset specified domain name, and whether it contains the preset key field. Based on the current access environment, it automatically matches and switches the first access domain name to the second access domain name. This application enables the system to switch domain names without restarting the project, thus improving the system development efficiency.
[0011] Optional, also includes:
[0012] Determine if authorization is required; if so, retrieve authorization data from the browser.
[0013] Based on the authorized data, configure the authorization parameters in the second access domain name.
[0014] By adopting the above technical solution, when authorization is required, the authentication token value stored in the browser's cookie and session is obtained and configured into the second access domain, thereby achieving seamless access to the authorization system.
[0015] Optionally, the second access domain name includes a virtual environment access domain name, a development environment access domain name, a test environment access domain name, a pre-release environment access domain name, and a production environment access domain name.
[0016] Optionally, the step of switching the first access domain name to a second access domain name that matches the server parameter based on a preset configuration file includes:
[0017] Obtain the feature values of the server parameters;
[0018] Determine whether the configuration file contains a second access domain name that matches the feature value. If yes, switch the first access domain name to the second access domain name that matches the feature value. If no, output the first error message.
[0019] By adopting the above technical solution, the first error message indicates that the characteristic input of the server parameter is incorrect.
[0020] Optionally, obtaining authorization data in the browser then includes:
[0021] Determine whether the authorization data was successfully obtained. If so, configure the authorization parameters in the second access domain name based on the authorization data; otherwise, output the second error message.
[0022] By adopting the above technical solution, the second error message indicates that the authorization data acquisition failed.
[0023] Optionally, the preset key fields include a first preset key field and a second preset key field; the step of determining the preset key fields in the first access domain name and switching the first access domain name to the second access domain name according to the determination result and the configuration file includes:
[0024] Determine whether the access domain name contains the first preset key field. If so, switch the access domain name to the test environment access domain name corresponding to the first preset key field.
[0025] Determine whether the access domain name contains the second preset key field. If so, switch the access domain name to the pre-release environment access domain name corresponding to the second preset key field.
[0026] Determine whether the access domain name contains the first preset key field or the second preset key field. If not, switch the access domain name to the production environment access domain name.
[0027] By adopting the above technical solution, the improvement
[0028] Secondly, this application provides an access environment switching system, which adopts the following technical solution.
[0029] An access environment switching system includes:
[0030] The acquisition module is used to obtain the first access domain name;
[0031] The first judgment module is used to determine whether the first access domain name contains the server parameter. If so, it switches the first access domain name to a second access domain name that matches the server parameter based on a preset configuration file.
[0032] The second judgment module is used to determine whether the first access domain name is a preset specified domain name when the first judgment module determines that it is not. If it is, the first access domain name is switched to the second access domain name corresponding to the preset specified domain name based on the configuration file.
[0033] The third judgment module is used to determine the preset key field in the first access domain name when the second judgment module determines that it is not true, and to switch the first access domain name to the second access domain name according to the judgment result and the configuration file.
[0034] By adopting the above technical solution, the first access domain name is switched to the second access domain name by combining the first judgment module, the second judgment module and the third judgment module with the configuration file. When switching domain names in system development, this application does not require restarting the project, thus improving the efficiency of system development.
[0035] Optional, also includes:
[0036] The fourth judgment module is used to determine whether authorization is required. If so, it retrieves the authorization data from the browser.
[0037] The authorization configuration module is used to configure authorization parameters in the second access domain name based on the authorization data.
[0038] By adopting the above technical solution, when authorization is required, the authentication token value in the browser's cookie and session is obtained. By configuring the authentication token value in the second access domain, seamless access to the authorization system can be achieved.
[0039] Fourthly, this application provides a computer device that adopts the following technical solution.
[0040] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the method as described in any of the first aspects above.
[0041] Fifthly, this application provides a computer-readable storage medium, which adopts the following technical solution.
[0042] A computer-readable storage medium storing a computer program that can be loaded by a processor and execute the methods described in any of the first aspects above.
[0043] In summary, this application includes at least the following beneficial effects:
[0044] This application uses a pre-configured configuration file, which contains a second access domain name, server parameters, a specified domain name, and a mapping between preset key fields and the second access domain name. After obtaining the first access domain name, it sequentially checks whether the first access domain name contains server parameters, a preset specified domain name, and preset key fields. Based on the currently accessed first access domain name, it automatically matches the corresponding second access domain name, preventing the need to restart the project when switching domain names and improving project development efficiency. Attached Figure Description
[0045] Figure 1 This is a flowchart illustrating one implementation of the access environment switching method of this application;
[0046] Figure 2 This is a detailed flowchart illustrating one implementation of step S200 in the access environment switching method of this application;
[0047] Figure 3 This is a structural block diagram of one implementation of the access environment switching system of this application;
[0048] Explanation of reference numerals in the attached figures: 100, Acquisition module; 200, First judgment module; 300, Second judgment module; 400, Third judgment module; 410, First judgment subunit; 420, Second judgment subunit; 430, Third judgment subunit; 500, Fourth judgment module; 600, Authorization configuration module. Detailed Implementation
[0049] To make the objectives, technical solutions, and advantages of this invention clearer, the following description is provided in conjunction with the appendix. Figure 1-3The present invention will be further described in detail below with reference to embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. All other embodiments obtained by those skilled in the art based on the embodiments in this application without inventive effort are within the scope of protection of this application.
[0050] This application discloses a method for switching access environments.
[0051] As attached Figure 1 As shown, an access environment switching method includes:
[0052] S100, obtain the first access domain name;
[0053] Specifically, staff members enter the first access domain name in their browser to access the server, and the tool retrieves the content entered in the browser to complete the acquisition of the first access domain name.
[0054] S200, determine whether the first access domain name contains the server parameter. If so, based on the preset configuration file, switch the first access domain name to the second access domain name that matches the server parameter.
[0055] Specifically, the second access domain name includes virtual environment access domain name, development environment access domain name, test environment access domain name, pre-production environment access domain name, and production environment access domain name. The configuration file specifies the second access domain name and the mapping relationship between the server parameter and the second access domain name, as shown below: when the characteristic value of the server parameter is "mock", it corresponds to the virtual environment access domain name; when the characteristic value of the server parameter is "dev", it corresponds to the development environment access domain name; when the characteristic value of the server parameter is "test", it corresponds to the test environment access domain name; when the characteristic value of the server parameter is "pre", it corresponds to the pre-production environment access domain name; and when the characteristic value of the server parameter is "prod", it corresponds to the production environment access domain name. When the first access domain name is appended with "?server=xxx", it means that the first access domain name contains the "server" parameter. Based on the mapping between the "server" parameter and the second access domain name, the first access domain name is switched to the second access domain name that matches the "server" parameter. For example, when a browser accesses the system and appends the "server=test" parameter, it will change the request domain name of all servers to "test". That is, when the browser enters the first access domain name "local.sto.cn?server=test", which contains the "server" parameter, the first access domain name will be switched to the second access domain name "test.sto.cn / query" based on the configuration file.
[0056] As attached Figure 2As shown, step S200 specifically includes sub-steps S210-S220:
[0057] S210, obtain the characteristic values of the server parameters;
[0058] Specifically, the characteristic values of the server parameter are configured by the developers. The characteristic values of the server parameter include test, pre, and prod. This application uses a unified configuration specification to clarify the standardized coding method, enumeration naming, and request sending method, thereby preventing different developers from having arbitrary coding habits and reducing subsequent maintenance costs.
[0059] S220: Determine whether a second access domain name matching the feature value is configured in the configuration file. If yes, switch the first access domain name to the second access domain name matching the feature value. If no, output the first error message.
[0060] Specifically, when a browser accesses the server, it first obtains the characteristic value of the server parameter. test matches the test environment, pre matches the pre-production environment, and prod matches the production environment. If the characteristic value does not match the second access domain name in the configuration file, the first error message is output.
[0061] S300, if the first access domain does not contain the server parameter, then determine whether the first access domain is the preset specified domain. If so, then based on the configuration file, switch the first access domain to the second access domain corresponding to the preset specified domain.
[0062] S400 If the first access domain does not contain the server parameter and the first access domain is not a preset specified domain, then determine the preset key field in the first access domain, and switch the first access domain to the second access domain according to the determination result and the configuration file.
[0063] Specifically, the preset key fields include a first preset key field and a second preset key field. If the first access domain contains the first preset key field, the first access domain will be switched to the test environment access domain corresponding to the first preset key field. The first preset key field is set by the staff and includes: "daily", "test", "127.0.0.1", "localhost" and "local". When the browser enters the first access domain "local.sto.cn", it will determine that the current access is to the test environment and automatically switch the first access domain to "test.sto.cn / query".
[0064] If the first access domain contains the second preset key field, the access domain will be switched to the pre-release environment access domain corresponding to the second preset key field; the second preset key field is set by the staff and includes "pre";
[0065] If the first access domain does not contain either the first preset key field or the second preset key field, the access domain will be switched to the production environment access domain.
[0066] As a further implementation of the access environment switching method, it also includes:
[0067] S500 determines whether authorization is required; if so, it retrieves authorization data from the browser.
[0068] Specifically, whether authorization is required is configured by staff in the configuration file. The authorization modes include: URL concatenation mode and header-carrying mode. When authorization is required, the authentication token value in the browser's cookie and session is obtained.
[0069] S600 configures authorization parameters in the second access domain name based on authorization data.
[0070] Specifically, after authorizing data in the browser, it also checks whether the authorization data was successfully obtained. If so, it configures the authorization parameters in the second access domain based on the authorization data; otherwise, it outputs the second error message.
[0071] This application discloses an access environment switching system.
[0072] As attached Figure 3 As shown, an access environment switching system includes:
[0073] Module 100 is used to obtain the first access domain name;
[0074] The first judgment module 200 is used to determine whether the first access domain name contains the server parameter. If so, it switches the first access domain name to the second access domain name that matches the server parameter based on the preset configuration file.
[0075] The second judgment module 300 is used to determine whether the first access domain name is a preset specified domain name when the first judgment module 200 determines that it is not. If it is, the first access domain name is switched to the second access domain name corresponding to the preset specified domain name based on the configuration file.
[0076] The third judgment module 400 is used to judge the preset key fields in the first access domain name when the second judgment module 300 judges negative, and to switch the first access domain name to the second access domain name according to the judgment result and the configuration file.
[0077] In this embodiment, the first access domain name is switched to the second access domain name by three modules, namely the first judgment module 200, the second judgment module 300, and the third judgment module 400, in combination with the configuration file. This application does not require restarting the project when switching domain names during system development, thus improving system development efficiency.
[0078] As one implementation of the third judgment module 400, the third judgment module 400 includes:
[0079] The first judgment subunit 410 is used to determine whether the first access domain name contains the first preset key field. If so, the first access domain name is switched to the test environment access domain name corresponding to the first preset key field.
[0080] The first judgment subunit 410 is used to determine whether the first access domain name contains the second preset key field. If so, the first access domain name is switched to the pre-release environment access domain name corresponding to the second preset key field.
[0081] The first judgment subunit 410 is used to determine whether the first access domain name contains the first preset key field or the second preset key field. If not, the first access domain name is switched to the production environment access domain name.
[0082] As a further implementation of the access environment switching system, it also includes:
[0083] The fourth judgment module 500 is used to determine whether authorization is required. If so, the authorization data is obtained from the browser.
[0084] The authorization configuration module 600 is used to configure authorization parameters in the second access domain name based on authorization data.
[0085] In this embodiment, when authorization is required, the authentication token value in the browser's cookie and session is obtained. By configuring the authentication token value in the second access domain, seamless access to the authorization system is achieved.
[0086] It should be noted that the descriptions of each embodiment in the above embodiments have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0087] This application discloses a computer device.
[0088] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the method as described above.
[0089] This application discloses a computer-readable storage medium.
[0090] A computer-readable storage medium storing a computer program that can be loaded by a processor and executed by any of the methods described above.
[0091] It should be noted that, for the sake of convenience and brevity, the above division of functional units and modules is used as an example. In actual applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the system can be divided into different functional units or modules to complete all or part of the functions described above.
[0092] The above are all preferred embodiments of this application, and are not intended to limit the scope of protection of this application. Therefore, all equivalent changes made in accordance with the structure, shape and principle of this application should be covered within the scope of protection of this application.
Claims
1. An access environment switching method characterized by comprising: The method comprises the following steps: acquiring a first access domain name; determining whether the first access domain name contains a server parameter, if yes, switching the first access domain name to a second access domain name matched with the server parameter based on a preset configuration file, if no, determining whether the first access domain name is a preset specified domain name, if yes, switching the first access domain name to a second access domain name corresponding to the preset specified domain name based on the configuration file, if no, determining a preset key field in the first access domain name, and switching the first access domain name to a second access domain name according to the determination result and the configuration file; The method further comprises the following steps: determining whether authorization is needed, if yes, acquiring authorization data in a browser; configuring an authorization parameter in the second access domain name based on the authorization data; The second access domain name comprises a virtual environment access domain name, a development environment access domain name, a test environment access domain name, a pre-release environment access domain name and a production environment access domain name; The step of switching the first access domain name to a second access domain name matched with the server parameter based on a preset configuration file comprises the following steps: acquiring a characteristic value of the server parameter; determining whether the configuration file is configured with the second access domain name matched with the characteristic value, if yes, switching the first access domain name to the second access domain name matched with the characteristic value, if no, outputting a first error message; The step of acquiring authorization data in a browser comprises the following steps: determining whether the authorization data is acquired successfully, if yes, configuring an authorization parameter in the second access domain name based on the authorization data, if no, outputting a second error message; The preset key field comprises a first preset key field and a second preset key field; the step of determining a preset key field in the first access domain name and switching the first access domain name to a second access domain name according to the determination result and the configuration file comprises the following steps: determining whether the first access domain name contains the first preset key field, if yes, switching the first access domain name to the test environment access domain name corresponding to the first preset key field; determining whether the first access domain name contains the second preset key field, if yes, switching the first access domain name to the pre-release environment access domain name corresponding to the second preset key field; determining whether the first access domain name contains the first preset key field or the second preset key field, if no, switching the first access domain name to the production environment access domain name.
2. An access environment switching system characterized by comprising: The method comprises the following steps: an acquiring module (100) is configured to acquire a first access domain name; a first determining module (200) is configured to determine whether the first access domain name contains a server parameter, if yes, switching the first access domain name to a second access domain name matched with the server parameter based on a preset configuration file, the step of switching the first access domain name to a second access domain name matched with the server parameter based on a preset configuration file comprises the following steps: acquiring a characteristic value of the server parameter; determining whether the second access domain name matching the feature value is configured in the configuration file, and if yes, switching the first access domain name to the second access domain name matching the feature value; and if no, outputting first error information; the second determining module (300) is configured to, when the first determining module (200) determines no, determine whether the first access domain name is a preset specified domain name, and if yes, switch the first access domain name to a second access domain name corresponding to the preset specified domain name based on the configuration file; the second access domain name includes a virtual environment access domain name, a development environment access domain name, a test environment access domain name, a pre-release environment access domain name, and a production environment access domain name; the third determining module (400) is configured to, when the second determining module (300) determines no, determine a preset key field in the first access domain name, and switch the first access domain name to a second access domain name according to a determination result and the configuration file; the preset key field includes a first preset key field and a second preset key field; the determination of the preset key field in the first access domain name and the switching of the first access domain name to the second access domain name according to the determination result and the configuration file include: determining whether the first access domain name contains the first preset key field, and if yes, switching the first access domain name to the test environment access domain name corresponding to the first preset key field; determining whether the first access domain name contains the second preset key field, and if yes, switching the first access domain name to the pre-release environment access domain name corresponding to the second preset key field; determining whether the first access domain name contains the first preset key field or the second preset key field, and if no, switching the first access domain name to the production environment access domain name; the fourth determining module (500) is configured to determine whether authorization is needed, and if yes, acquire authorization data in a browser; the acquisition of the authorization data in the browser includes: determining whether the authorization data is acquired successfully, and if yes, configuring authorization parameters in the second access domain name based on the authorization data; and if no, outputting second error information; the authorization configuring module (600) is configured to configure authorization parameters in the second access domain name based on the authorization data. The computer program stored in the memory and executable on the processor can be loaded and executed by the processor to implement the method of claim 1.
3. A computer device, characterized by: The computer program stored in the memory and executable on the processor can be loaded and executed by the processor to implement the method of claim 1.
4. A computer-readable storage medium, characterized in that:
Citation Information
Patent Citations
Domain name processing method and device, readable storage medium and electronic device
CN110149423A
Test environment switching method, device and equipment and readable storage medium
CN113535586A