Multi-version control method, system, device and storage medium under API framework

By introducing a unified API entrance and routing pool into the API framework, the isolation of the main version and the minor version directory is achieved, which solves the problems of excessive URL and version history tracking in the API framework version iteration and management, and improves the maintainability and performance of the system. Scalability to support smooth transition to new versions.

CN118535140BActive Publication Date: 2024-10-01CHENGDU VINCHIN TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411011748.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-26
Publication Date
2024-10-01
Estimated Expiration
2044-07-26

AI Technical Summary

Technical Problem

The existing API framework has problems in version iteration and management, such as too long URLs, increased maintenance difficulty, and difficulty in tracking version history, which results in increased version control complexity and difficulty in meeting the needs of developers and customers.

Method used

The design of a unified API entrance and routing pool is adopted, and the main version and minor version directories are isolated from each other. The routing pool is used to save the mapping relationship rules between the request matching path and the version directory to achieve flexible routing and response processing of version call requests.

Benefits of technology

It achieves modular and independent updates of functions and business logic, reduces coupling, supports seamless iteration and backward compatibility, ensures long-term stability of the system, and meets complex business needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535140B_ABST
    Figure CN118535140B_ABST
Patent Text Reader

Abstract

The present invention relates to a multi-version control method, system, device and storage medium under an API framework, and belongs to the field of computer technology. The method used for the server side includes: creating an API framework with a unified API entry and a routing pool, wherein the API framework is provided with mutually isolated main version directories, and the main version directory is provided with mutually isolated sub-version directories; the API entry receives a version call request, parses it, and then routes it to the target version directory; the API framework calls the target version directory to process the client version call request, and sends the response back to the client. The method used for the client side includes: sending a version call request to the server side; receiving a server-side response, and executing the business logic of the target version directory. The present invention realizes the modularization of functions and business logic, and each version module can be independently updated and deployed, which can not only meet the version iteration and maintenance requirements of developers, but also meet the requirements of customers to flexibly call the required version through API.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer technology and relates to a multi-version control method, system, device and storage medium under an API framework. Background Art

[0002] An API framework is a software architecture pattern that defines a set of rules, guidelines, and tools for building, integrating, and using APIs. The core purpose of an API framework is to provide a standardized method that enables different software components or services to communicate and interact with each other.

[0003] In some application scenarios, customers have the need to interact with the developer's products or services through APIs to complete their own business. For example, customers may prefer to customize the user interface (UI) to meet specific business needs or brand characteristics, rather than directly using the UI provided by the developer. For another example, customers may use APIs to access specific data analysis tools to track and analyze their own user behavior, thereby optimizing their own services and products.

[0004] In order to stay competitive, software developers frequently iterate and update product versions. Rapid version iterations will produce numerous major and minor versions, which all need to be maintained, managed, and updated. At the same time, helping customers retrieve the corresponding versions through APIs to meet their business needs is also a very important task.

[0005] Currently, existing technologies mainly use path version control, which distinguishes different API versions by embedding version numbers in the URL path of the API, such as / api / V1 / resource. This method is easy to understand and implement because of its intuitiveness, and customers can quickly identify the API version they are using. However, as product iterations and the number of versions increase, the continuously accumulated version numbers in the path may cause the URL to become lengthy, increasing the difficulty of maintenance. In addition, this accumulation may also make it difficult to track the version history of the API, increasing the complexity of version control.

[0006] Therefore, how to help developers iterate and maintain versions of long-running systems, and help customers easily and accurately retrieve the required version codes through APIs, is a technical problem that urgently needs to be solved. Summary of the invention

[0007] In order to solve the technical problems in the above-mentioned background technology, the present invention provides a multi-version control method, system, device and storage medium under an API framework.

[0008] The technical solution of the present invention to solve the above technical problems is as follows:

[0009] In a first aspect, a multi-version control method under an API framework is provided, which is used on a server side, and the method comprises the steps of:

[0010] An API framework with a unified API entry and routing pool is created on the server. The API framework has several isolated main version directories, and each main version directory has several isolated sub-version directories. The routing pool stores the mapping relationship rules between the request matching path and the specified version directory.

[0011] The API entry receives a client version call request, which includes a URL path and a specified HTTP header, or a URL path and query parameters;

[0012] The API framework parses the version call request, and then routes the version call request to the target version directory according to the routing pool mapping relationship rules;

[0013] Based on the routing results, the API framework calls the target version directory to process the client version call request, and then generates a response and sends it back to the client.

[0014] In a second aspect, a multi-version control method under an API framework is provided, which is used for a client, and the method comprises the steps of:

[0015] Send a version call request to the server, which includes the URL path and the specified HTTP header, or the URL path and query parameters;

[0016] Receive the response of the server, and execute the business logic of the target version directory according to the response, the business logic is obtained by the API framework parsing the version call request, and then routing the version call request to the target version directory according to the routing pool mapping relationship rules; the API framework has an API framework with a unified API entry and routing pool, and several mutually isolated main version directories are set in the API framework, and several mutually isolated sub-version directories are set in each main version directory; the routing pool saves the mapping relationship rules between the request matching path and the specified version directory.

[0017] In a third aspect, a multi-version control system under an API framework is provided, which is used on a server side, and the system includes:

[0018] The API framework creation module is used to create an API framework with a unified API entry and routing pool on the server. The API framework is provided with several mutually isolated main version directories, and each main version directory is provided with several mutually isolated sub-version directories; the routing pool stores the mapping relationship rules between the request matching path and the specified version directory;

[0019] A version call request receiving module is used for receiving a client version call request from an API entry, where the version call request includes a URL path and a specified HTTP header, or a URL path and query parameters;

[0020] The parsing routing module is used by the API framework to parse version call requests, and then route the version call requests to the target version directory according to the routing pool mapping relationship rules;

[0021] The response module is used to process the client version call request based on the routing result and the API framework calls the target version directory, and then generates a response and sends it back to the client.

[0022] In a fourth aspect, a multi-version control system under an API framework is provided, which is used for a client, and the system includes:

[0023] A version call request sending module is used to send a version call request to the server, where the version call request includes a URL path and a specified HTTP header, or a URL path and query parameters;

[0024] A response receiving execution module is used to receive a response from the server and execute the business logic of the target version directory according to the response. The business logic is obtained by parsing the version call request by the API framework, and then routing the version call request to the target version directory according to the routing pool mapping relationship rules; the API framework has an API framework with a unified API entry and a routing pool, and a number of mutually isolated main version directories are arranged in the API framework, and a number of mutually isolated sub-version directories are arranged in each main version directory; the routing pool stores the mapping relationship rules between the request matching path and the specified version directory.

[0025] In a fifth aspect, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the multi-version control method under the API framework are implemented.

[0026] In a sixth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, a multi-version control method under the above-mentioned API framework is implemented.

[0027] The beneficial effects of the present invention are:

[0028] (1) The present invention realizes the modularization of functions and business logic. Each version module is updated and deployed independently, which reduces coupling and improves maintainability and scalability.

[0029] (2) The present invention implements a flexible version selection mechanism through URL path and specified HTTP header, or URL path and query parameters, supporting seamless iteration, backward compatibility and historical query;

[0030] (3) The framework of the present invention supports smooth transition to new versions, ensuring the long-term stability of the system. It also supports the operation of multiple versions and modules to meet complex business needs. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0032] Figure 1 A flowchart of a multi-version control method under an API framework in a server-side provided in an embodiment of the present invention.

[0033] Figure 2 A schematic diagram of the structure of multiple versions running in parallel in the API framework provided in an embodiment of the present invention.

[0034] Figure 3 A schematic diagram of the structure of the main version directory and the secondary version directory in the API framework provided in an embodiment of the present invention.

[0035] Figure 4 A flowchart of a multi-version control method under an API framework in a client provided by an embodiment of the present invention.

[0036] Figure 5 A schematic diagram of the structure of a multi-version control system under an API framework in a server-side according to an embodiment of the present invention.

[0037] Figure 6 A schematic diagram of a module structure for creating an API framework in a server provided in an embodiment of the present invention.

[0038] Figure 7 A schematic diagram of the structure of a routing parsing module used in a server provided in an embodiment of the present invention.

[0039] Figure 8 A schematic diagram of the structure of a multi-version control system under an API framework in a client provided by an embodiment of the present invention.

[0040] Fig. 9 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention.

[0041] In the accompanying drawings, the components represented by the reference numerals are listed as follows:

[0042] 310, API framework creation module; 320, version call request receiving module; 330, parsing routing module; 340, response module; 3101, API framework preliminary creation unit; 3102, version directory creation unit; 3103, version control setting unit; 3104, routing pool setting unit; 3301, path and server version information acquisition unit; 3302, client target version information acquisition unit; 3303, target version directory routing unit; 410, version call request sending module; 420, response receiving execution module; 510, processor; 520, communication interface; 530, memory; 540, communication bus. DETAILED DESCRIPTION

[0043] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0044] As the core of software architecture, API framework provides a set of standardized rules and tools to simplify communication and interaction between different software components. It allows customers to meet specific business needs through APIs. However, with the acceleration of the life cycle of software products, developers need to frequently iterate versions. Although the traditional path version control method is intuitive and easy to implement, the long URL makes maintenance more difficult and version history difficult to track. How to help developers iterate and maintain the version of long-running systems, and help customers easily and accurately retrieve the required version code through APIs, is a technical problem that needs to be solved urgently.

[0045] In view of the above problems, an embodiment of the present invention provides a multi-version control method under an API framework, which is used on a server side. Figure 1 A schematic diagram of a multi-version control method under an API framework in a server-side according to an embodiment of the present invention is provided. Figure 1 As shown, the method includes:

[0046] Step S101, create an API framework with a unified API entry and a routing pool on the server. The API framework is provided with several mutually isolated main version directories, and each main version directory is provided with several mutually isolated sub-version directories; the routing pool stores the mapping relationship rules between the request matching path and the specified version directory.

[0047] It is understandable that the API entry usually refers to the target URL from which the client initiates the request. It is the starting point for accessing the backend server. It can be a single URL, and all API requests are accessed through this URL. In this embodiment, a unified API entry is set up to simplify the integration for the client. The client only needs to know a unified API entry URL and does not need to care about the specific address and details of the backend service, which improves the user experience. For the server side, the backend architecture can be hidden, and the architecture and deployment details of the backend service are not transparent to the client, which helps to protect the security and stability of the system. At the same time, it is also convenient for server-side maintenance, expansion, centralized monitoring and management: a unified API entry makes it easier to add new services or modify existing services, because these changes do not require the client to know, and through a single entry point, it is easier to implement monitoring, logging and performance analysis of API requests.

[0048] In addition, for the setting of the unified API entry, an API gateway can be set up, that is, an API gateway is additionally set up and used as a unified API entry to provide additional processing logic and security features; a reverse proxy method can also be used, that is, a reverse proxy server, such as Nginx or Apache, is configured to forward all API requests to the backend service. The embodiments of the present invention do not specifically limit this.

[0049] It can also be understood that a routing pool generally refers to a set of predefined service instances or resources that can be used to process requests. It may include a list of servers, service clusters, API versions, etc. Each member in the routing pool can process requests independently and is usually associated with specific routing rules. Therefore, the routing pool focuses on defining which resources client requests can be sent to, and dynamically adjusting them according to the status of server-side services. By establishing a routing pool, it is possible to more efficiently support the management of multiple versions, cope with complex version iteration situations, and ensure the stable and long-term operation of the system.

[0050] It is worth noting that in terms of the functionality and modularity of the API framework, this embodiment isolates the main version directory from the main version directory, and the sub-version directory within the main version directory from the sub-version directory, so that each version directory can be updated and deployed independently, and the business logic between versions does not interfere with each other, thereby ensuring that the client can call the required business logic code and facilitating software developers to effectively implement version iteration and maintenance.

[0051] Specifically, Figure 2 A schematic diagram of the structure of multiple versions in parallel in the API framework provided in this embodiment. Figure 2In the , V1 represents the main version V1, Vn represents the main version Vn, and the main versions do not interfere with each other; 0 to n following V1 represent the sub-versions V1.0 to V1.n under this main version. There may be countless sub-versions of this kind, and they do not interfere with each other; rev0 to revn following V1.0 (or V1.n) represent more detailed revisions after V1.0 (or V1.n), such as V1.0-rev0, V1.0-revn, V1.n-rev0, V1.n-revn. There may be countless revisions of this kind, and they do not interfere with each other.

[0052] In addition, each version module may be configured according to the needs of the developer, such as adding a revised version directory under the secondary version directory to further increase scalability; or setting up several secondary version directories under the main version directory, and setting configuration information, description files and operation codes under each secondary version directory. The embodiment of the present invention does not specifically limit this.

[0053] Step S102: The API entry receives a version call request from the client, where the version call request includes a URL path and a specified HTTP header, or a URL path and query parameters.

[0054] Step S103, the API framework parses the version call request, and then routes the version call request to the target version directory according to the routing pool mapping relationship rule.

[0055] Step S104, according to the routing result, the API framework calls the target version directory to process the client version call request, and then generates a response and sends it back to the client.

[0056] In the prior art, different API versions are mainly distinguished by embedding the version number in the URL path of the API, such as / api / V1 / resource, which provides an intuitive and easy-to-implement version management method that allows users and developers to quickly identify. However, with the increase of version numbers and other path parameters, the length of the URL may become quite long, which not only affects the appearance, but may also cause problems in certain environments with restrictions on URL length. Secondly, when the version control strategy of the API becomes complex, the path version control may not be flexible enough to adapt to changing needs. For example, if an API service needs to provide different data processing logic according to the laws and regulations of different regions, path version control may find it difficult to achieve such dynamic version selection.

[0057] In the embodiments of the present invention, the constructed API framework itself has the characteristics of high modularity, flexible routing mechanism and stable and controllable API entry. On this basis, it cooperates with a specific version call request, that is, selects the URL path with the specified HTTP header or query parameter. On the one hand, the required version can be dynamically specified and switched without changing the URL by passing the version information through the HTTP header or query parameter. On the other hand, it also provides additional scalability, allowing the client to request specific functions of a specific version as needed. Therefore, it can meet the version iteration and maintenance needs of developers and the needs of customers to flexibly call the required version code through the API.

[0058] Based on the above embodiment, in the method, step S101 includes:

[0059] Step S1011, creating an API framework on the server side, wherein the API framework has a unified API entry for receiving and responding to external requests.

[0060] Step S1012, create several mutually isolated main version directories in the API framework, create a general configuration information directory and a secondary version directory in each main version directory, the general configuration information directory and the secondary version directory are isolated from each other, and a first controller is set in the secondary version directory.

[0061] It is worth noting that a common configuration information directory is created in each main version directory. This directory is used to store configuration information shared by all sub-versions and revisions, such as database connection information, API keys, log configuration, etc. This centralized management facilitates maintenance and updates. At the same time, ensuring that the common configuration information directory is isolated from the sub-version directory can effectively avoid conflicts and misuse of configuration information.

[0062] In addition, a controller needs to be set in each sub-version directory. The controller is the core component in the API framework, responsible for processing client requests and returning responses. The controller contains business logic and data access logic. In this embodiment, the path of the version call request is resolved to the controller, which can receive requests and output responses.

[0063] Step S1013, setting version control in the API entry path to support operations of different versions of APIs.

[0064] It is understandable that version control here does not refer to a holistic method. Version control here is a technical means to implement version control in the API URL. More specifically, it can clearly distinguish different versions of the API in the API URL path for easy management and calling.

[0065] For users, setting version control in the API entry path allows them to explicitly select the API version they want to use through the URL path; for developers, setting version control in the API entry path makes it easier to manage and deploy different versions of the API.

[0066] Step S1014, creating a routing pool in the API framework, saving a number of request matching paths in the routing pool, and making a one-to-one correspondence between the request matching paths and the specified version directories to form a mapping relationship rule.

[0067] The method provided in this embodiment utilizes the isolation of version directories to ensure the centralized management and security of configuration information. The unified API entry and version control mechanism provide a clear structure and flexibility for the entire framework. The setting of the controller and the creation of the routing pool ensure that requests can be processed efficiently and accurately, thereby realizing a more efficient, more secure, scalable and easy-to-maintain API multi-version control framework.

[0068] Based on the above embodiment, in the method, step S1012 further includes:

[0069] Step S10121, a configuration file directory, a description directory and a language directory are created in the general configuration information directory;

[0070] Step S10122: A controller directory and a business logic extension directory are created in the secondary version directory, a revision directory is created in the business logic extension directory, and the revision directory stores a second controller.

[0071] For ease of understanding, Figure 3 As shown in the figure, we show the structure of the main version directory (V1) and the minor version directory (V1.0) in the API framework, and we explain the subdirectories in the main version directory and the minor version directory:

[0072] (1) Configuration file directory (config): Create a configuration file directory in the common configuration information directory to allow centralized storage of configuration files shared by all API versions, such as database configuration, server endpoints, etc.

[0073] (2) Description: Contains documentation on the use of the API, which may include how to use the API, parameter descriptions, version update logs, etc., to help users and developers understand how the API works and how to use it;

[0074] (3) Language directory (lang): used to store resource files that support multiple languages, so that the API can return responses in the corresponding language based on the language preference of the request;

[0075] (4) Controller directory: Create a controller directory in the secondary version directory to store controller code that handles specific business logic;

[0076] (5) Business logic extension directory (logic): provides an extension point that allows developers to add additional business logic processing modules as needed.

[0077] In addition, we create a revision directory in the business logic extension directory to store the second controller and provide revisions. Figure 3 In the above, app usually refers to the application program, which represents the version management part, that is, the root directory; alarm usually refers to the alarm or notification system, and the configuration information directory and the sub-version directory can be set under this directory for specific reminders.

[0078] In addition, some function directories may be added according to specific usage scenarios, such as adding a log directory and an environment directory to a configuration file directory, and adding a service directory (service) and a validation directory (validate) to a secondary version directory. This is not specifically limited in the embodiments of the present invention.

[0079] Different from the previous implementation method, this embodiment allows developers to expand and revise specific functions without affecting the main business logic, further improving the flexibility and maintainability of the API. At the same time, by creating a second controller in the business logic extension directory, the controller is modularized, so that different business logics can be processed by different controllers, which helps to reduce the coupling of the code. In addition, a clear directory also makes management more organized and professional.

[0080] Based on the above embodiment, in the method, step S103 includes:

[0081] Step S1031, the API framework parses the URL path in the client version call request to obtain the request path and server API version information;

[0082] Step S1032, the API framework parses the HTTP header or query parameter specified in the client version call request to obtain the client target version information;

[0083] Step S1033: The API framework matches the parsing result through the mapping relationship rules in the routing pool and routes the version call request to the target version directory.

[0084] It is understood that the server API version information refers to the version information that the API server can provide, which is generally specified in the URL path. The client target version information refers to the information sent by the client in the request, indicating that it can accept or expect to interact with a specific version.

[0085] The API framework should provide a clear and flexible mechanism to parse client version call requests and map them to the corresponding version directory. By parsing the URL path, query parameters, or special HTTP header information, it can handle requests from clients more flexibly, allowing clients to specify the target version in different ways.

[0086] like Figure 4 As shown, an embodiment of the present invention provides a multi-version control method under an API framework, which is used for a client, and the method includes the steps of:

[0087] Step S201, sending a version call request to the server, the version call request including a URL path and a specified HTTP header, or a URL path and query parameters;

[0088] Step S202, receiving the response of the server, and executing the business logic of the target version directory according to the response, the business logic is obtained by the API framework parsing the version call request, and then routing the version call request to the target version directory according to the routing pool mapping relationship rules; the API framework has an API framework with a unified API entry and a routing pool, and a number of mutually isolated main version directories are set in the API framework, and each main version directory is set in a number of mutually isolated sub-version directories; the routing pool saves the mapping relationship rules between the request matching path and the specified version directory.

[0089] Compared with the existing technology, the client can easily and accurately retrieve the required version code through a specific version call request. The unified API entry also allows the client to not need to worry about the specific address and details of the backend service, thereby improving the user experience.

[0090] like Figure 5 As shown, an embodiment of the present invention provides a multi-version control system under an API framework, which is used on a server side. The system includes:

[0091] The API framework creation module 310 is used to create an API framework with a unified API entry and a routing pool on the server. The API framework is provided with a number of mutually isolated main version directories, and each main version directory is provided with a number of mutually isolated sub-version directories; the routing pool stores the mapping relationship rules between the request matching path and the specified version directory;

[0092] A version call request receiving module 320 is used for receiving a version call request from a client when an API entry is received. The version call request includes a URL path and a specified HTTP header, or a URL path and query parameters.

[0093] Parsing and routing module 330, used for the API framework to parse the version call request, and then route the version call request to the target version directory according to the routing pool mapping relationship rule;

[0094] The response module 340 is used to process the client version call request by the API framework calling the target version directory according to the routing result, and then form a response and send it back to the client.

[0095] Based on the above embodiments, Figure 6 As shown, the API framework creation module 310 includes:

[0096] An API framework preliminary creation unit 3101 is used to create an API framework on the server side, wherein the API framework has a unified API entry for receiving and responding to external requests;

[0097] A version directory creation unit 3102 is used to create several mutually isolated main version directories in the API framework, and create a general configuration information directory and a secondary version directory in each main version directory. The general configuration information directory and the secondary version directory are mutually isolated, and a first controller is provided in the secondary version directory;

[0098] A version control setting unit 3103, used to set version control in the API entry path, used to support the operation of different versions of API;

[0099] The routing pool setting unit 3104 is used to create a routing pool in the API framework, and save a number of request matching paths in the routing pool according to the version directory. The request matching paths correspond to the version directories one by one to form a mapping relationship rule.

[0100] Based on the above embodiments, Figure 7 As shown, the parsing routing module 330 includes:

[0101] Path and server version information acquisition unit 3301, used for the API framework to parse the URL path in the client version call request to obtain the request path and server API version information;

[0102] The client target version information acquisition unit 3302 is used for the API framework to parse the HTTP header or query parameter specified in the client version call request to obtain the client target version information;

[0103] The target version directory routing unit 3303 is used for the API framework to match the parsing result through the mapping relationship rule in the routing pool and route the version call request to the target version directory.

[0104] In the embodiment of the present invention, the framework supports smooth transition to a new version to ensure the long-term stability of the system, while supporting the operation of multiple versions and modules to meet complex business needs.

[0105] like Figure 8 As shown, an embodiment of the present invention provides a multi-version control system under an API framework, which is used for a client, and the system includes:

[0106] A version call request sending module 410 is used to send a version call request to the server, where the version call request includes a URL path and a specified HTTP header, or a URL path and query parameters;

[0107] The response receiving execution module 420 is used to receive the response of the server and execute the business logic of the target version directory according to the response. The business logic is obtained by the API framework parsing the version call request, and then routing the version call request to the target version directory according to the routing pool mapping relationship rules; the API framework has an API framework with a unified API entry and a routing pool, and a number of mutually isolated main version directories are arranged in the API framework, and a number of mutually isolated sub-version directories are arranged in each main version directory; the routing pool saves the mapping relationship rules between the request matching path and the specified version directory.

[0108] Fig. 9 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, such as Fig. 9 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other through the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the following method: an API framework with a unified API entry and a routing pool is created on the server, wherein the API framework is provided with a number of mutually isolated main version directories, and each main version directory is provided with a number of mutually isolated sub-version directories; the routing pool stores the mapping relationship rules between the request matching path and the specified version directory; the API entry receives the client version call request, and the version call request includes the URL path and the specified HTTP header, or the URL path and the query parameter; the API framework parses the version call request, and then routes the version call request to the target version directory according to the routing pool mapping relationship rules; according to the routing result, the API framework calls the target version directory to process the client version call request, and then forms a response and sends it back to the client.

[0109] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0110] In this embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the multi-version control method under the API framework described in the above embodiment is implemented.

[0111] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.

[0112] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0113] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0114] Computer program code for performing the operation of the present invention may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, Ruby, Go, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0115] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the patent of the present invention. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.

Claims

1. A multi-version control method under an API framework, characterized in that: For the server side, the method comprises the steps of: An API framework with a unified API entry and routing pool is created on the server. The API framework has several isolated main version directories, and each main version directory has several isolated sub-version directories. The routing pool stores the mapping relationship rules between the request matching path and the specified version directory. The API entry receives a client version call request, which includes a URL path and a specified HTTP header, or a URL path and query parameters; The API framework parses the version call request, and then routes the version call request to the target version directory according to the routing pool mapping relationship rules; According to the routing result, the API framework calls the target version directory to process the client version call request, and then forms a response and sends it back to the client; The step of creating an API framework with a unified API entry and a routing pool on the server also includes: Creating an API framework on the server side, wherein the API framework has a unified API entry for receiving and responding to external requests; Create several mutually isolated main version directories in the API framework. Create a general configuration information directory and a sub-version directory in each main version directory. The general configuration information directory and the sub-version directory are isolated from each other. The general configuration information directory is used to store configuration information shared by all sub-versions and revisions. The sub-version directory is provided with a first controller, which is responsible for processing client requests and returning responses. It contains business logic and data access logic. The path of the version call request is resolved to the controller. Set up version control in the API entry path to support operations on different versions of the API; Create a routing pool in the API framework, save several request matching paths in the routing pool, and correspond the request matching paths to the specified version directories one by one to form a mapping relationship rule.

2. The multi-version control method under the API framework according to claim 1 is characterized in that: The step of creating several mutually isolated main version directories in the API framework, and creating a general configuration information directory and a secondary version directory in each main version directory, further includes: The general configuration information directory includes a configuration file directory, a description directory and a language directory; A controller directory and a business logic extension directory are created in the secondary version directory, a revised version directory is created in the business logic extension directory, and the revised version directory stores the second controller.

3. The multi-version control method under the API framework according to claim 1 is characterized in that: The API framework parses the version call request, and then routes the version call request to the target version directory according to the routing pool mapping relationship rule, and also includes: The API framework parses the URL path in the client version call request to obtain the request path and server API version information; The API framework parses the HTTP header or query parameter specified in the client version call request to obtain the client target version information; The API framework matches the parsing results through the mapping relationship rules in the routing pool and routes the version call request to the target version directory.

4. A multi-version control method under an API framework, characterized in that: For a client, the method comprises the steps of: Send a version call request to the server, which includes the URL path and the specified HTTP header, or the URL path and query parameters; Receive the server's response and execute the business logic of the target version directory according to the response. The business logic is obtained by the API framework parsing the version call request and then routing the version call request to the target version directory according to the routing pool mapping relationship rules; The API framework has a unified API entry and routing pool. The API entry is used to receive and respond to external requests. Several mutually isolated main version directories are set in the API framework. A general configuration information directory and a sub-version directory are created in each main version directory. The general configuration information directory and the sub-version directory are isolated from each other. The general configuration information directory is used to store configuration information shared by all sub-versions and revised versions. A first controller is set in the sub-version directory. The first controller is responsible for processing client requests and returning responses, including business logic and data access logic. The path of the version call request is parsed to the controller; version control is also set in the API entry path to support the operation of different versions of API; The routing pool saves several request matching paths, and corresponds the request matching paths to the specified version directories one by one to form a mapping relationship rule.

5. A multi-version control system under an API framework, characterized in that: For the server side, the system comprises: The API framework creation module is used to create an API framework with a unified API entry and routing pool on the server. The API framework is provided with several mutually isolated main version directories, and each main version directory is provided with several mutually isolated sub-version directories; the routing pool stores the mapping relationship rules between the request matching path and the specified version directory; A version call request receiving module is used for receiving a client version call request from an API entry, where the version call request includes a URL path and a specified HTTP header, or a URL path and query parameters; The parsing routing module is used by the API framework to parse version call requests, and then route the version call requests to the target version directory according to the routing pool mapping relationship rules; The response module is used to process the client version call request based on the routing result and the API framework calls the target version directory, and then generates a response and sends it back to the client; The API framework creation module further includes: An API framework preliminary creation unit, used to create an API framework on the server side, wherein the API framework has a unified API entry for receiving and responding to external requests; A version directory creation unit is used to create several mutually isolated main version directories in the API framework. A general configuration information directory and a sub-version directory are created in each main version directory. The general configuration information directory and the sub-version directory are mutually isolated. The general configuration information directory is used to store configuration information shared by all sub-versions and revisions. A first controller is provided in the sub-version directory. The first controller is responsible for processing client requests and returning responses, and includes business logic and data access logic. The path of the version call request is resolved to the controller. A version control setting unit is used to set version control in the API entry path to support the operation of different versions of APIs; The routing pool setting unit is used to create a routing pool in the API framework. According to the version directory, a number of request matching paths are saved in the routing pool. There is a one-to-one correspondence between the request matching path and the version directory to form a mapping relationship rule.

6. A multi-version control system under an API framework, characterized in that: For a client, the system comprises: A version call request sending module is used to send a version call request to the server, where the version call request includes a URL path and a specified HTTP header, or a URL path and query parameters; A response receiving execution module is used to receive a response from the server and execute the business logic of the target version directory according to the response. The business logic is obtained by parsing the version call request by the API framework, and then routing the version call request to the target version directory according to the routing pool mapping relationship rule; the API framework has a unified API entry and a routing pool. The API entry is used to receive and respond to external requests. There are several mutually isolated main version directories in the API framework. A general configuration information directory and a sub-version directory are created in each main version directory. The general configuration information directory and the sub-version directory are isolated from each other. Among them, the general configuration information directory is used to store configuration information shared by all sub-versions and revised versions. A first controller is provided in the sub-version directory. The first controller is responsible for processing client requests and returning responses, which includes business logic and data access logic. The path of the version call request is parsed to the controller; version control is also set in the API entry path to support operations of different versions of APIs; the routing pool saves several request matching paths, and one-to-one correspondence is made between the request matching paths and the specified version directories to form a mapping relationship rule.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the multi-version control method under the API framework as described in any one of claims 1 to 3 are implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the multi-version control method under the API framework as described in any one of claims 1 to 3 is implemented.

Citation Information

Patent Citations

  • Remote file control system based on routers

    CN104539665A

  • API version control method and device in API gateway and storage medium

    CN112612508A

  • Application implementation method and device, electronic equipment and storage medium

    CN115357282A

  • Data capturing method and device and related equipment

    CN117370464A

  • Version compatibility method, device and equipment and computer readable storage medium

    CN118012500A