A request processing method, device, equipment and storage medium

By analyzing template definition and building parsing result requests, the compatibility of the front-end API design pattern is achieved, solving the problem of high transformation costs and high workload when migrating RESTful API to GraphQL API, and realizing some architecture transformation without affecting the business system Functional effect.

CN114816403BActive Publication Date: 2024-11-12DOUYIN VISION CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210411950.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-19
Publication Date
2024-11-12
Estimated Expiration
2042-04-19

AI Technical Summary

Technical Problem

Development based on RESTful APIs requires the development of different APIs for different front-end business scenarios, which increases the workload of developers, and the transformation costs are high when migrating the front-end and back-end to a software architecture that supports GraphQL.

Method used

By receiving the request to be parsed from the first application program interface API, determining the resolution template definition, obtaining the data source and variable type of the target variable, building a parsing result request, and sending it to the preset API, realizing the front-end and back-end design based on different APIs The compatibility of the mode supports some architecture transformation without affecting the functions of the business system.

Benefits of technology

Reduces the cost of migrating RESTful APIs to GraphQL APIs, reduces the workload for developers, and allows only partial transformation of the backend architecture to maintain the functional integrity of the business system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114816403B_ABST
    Figure CN114816403B_ABST
Patent Text Reader

Abstract

The present disclosure provides a request processing method, apparatus, device and storage medium, the method comprising: receiving a request to be parsed from a first application program interface API, determining a parsing template definition corresponding to the first API, obtaining a variable value corresponding to the first target variable from the request to be parsed based on a data source of the first target variable, constructing a parsing result request corresponding to the request to be parsed based on the variable value and variable type corresponding to the first target variable, and sending the parsing result request to a preset API. The present disclosure parses the request to be parsed from the first API into a parsing result request recognizable by a preset API. Compared with the prior art of completely migrating the front-end and back-end to a software architecture supporting GraphQL, the present disclosure supports only modifying part of the architecture of the business system (such as the back-end), and may not affect the functions of the business system, thereby reducing the resulting modification costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data processing, and in particular to a request processing method, device, equipment and storage medium. Background Art

[0002] REST (Representational State Transfer) is a design style and development method for network applications. The RESTful API (Application Programming Interface) encapsulated based on REST makes it very easy to separate the front-end and back-end and interact with data, so RESTful API has become a popular software architecture design pattern in the Internet field.

[0003] However, since the data required by different business scenarios on the front end may be similar but also have some differences, and based on the development characteristics of RESTful API, different RESTful APIs need to be developed to meet the needs of the front end in the face of the above business scenarios, which increases the workload of developers. Therefore, there is often a need to transform business systems developed based on RESTful API. Currently, GraphQL provides a more effective, powerful and flexible alternative to REST.

[0004] In the related technology, there is a transformation plan in which the front-end and back-end are completely migrated to a software architecture that supports GraphQL (Graph Query Language), and all interfaces use GraphQL API, but the resulting transformation cost is relatively high. Summary of the invention

[0005] In order to solve the above technical problems, an embodiment of the present disclosure provides a request processing method.

[0006] In a first aspect, the present disclosure provides a request processing method, the method comprising:

[0007] Receiving a request to be parsed from a first application program interface (API); wherein the first API is generated based on a first API design pattern;

[0008] Determine a parsing template definition corresponding to the first API; wherein the parsing template definition is determined based on the second API design pattern, and the parsing template definition defines a data source of a first target variable corresponding to the first API and a variable type of the first target variable, and the first target variable is used to construct a parsing result request corresponding to the request to be parsed;

[0009] Based on the data source of the first target variable, obtaining a variable value corresponding to the first target variable from the request to be parsed;

[0010] Based on the variable value and variable type corresponding to the first target variable, a parsing result request corresponding to the request to be parsed is constructed, and the parsing result request is sent to a preset API; wherein the preset API is generated based on the second API design pattern.

[0011] In an optional implementation manner, the parsing template definition further defines an expression of a second target variable corresponding to the first API, a data source of an intermediate variable included in the expression, and a variable type of the second target variable, and the second target variable is used to construct a parsing result request corresponding to the request to be parsed;

[0012] Before constructing the parsing result request corresponding to the request to be parsed based on the variable value and variable type corresponding to the first target variable, the method further includes:

[0013] Based on the data source of the intermediate variable contained in the expression of the second target variable, obtaining a variable value corresponding to the intermediate variable;

[0014] Calculate the variable value corresponding to the second target variable based on the variable value corresponding to the intermediate variable and the expression;

[0015] Correspondingly, constructing a parsing result request corresponding to the request to be parsed based on the variable value and variable type corresponding to the first target variable includes:

[0016] Based on the variable values ​​and variable types respectively corresponding to the first target variable and the second target variable, a parsing result request corresponding to the request to be parsed is constructed.

[0017] In an optional implementation, constructing a parsing result request corresponding to the request to be parsed based on the variable value and the variable type corresponding to the first target variable includes:

[0018] Obtain a preset request template; wherein the preset request template is set based on the second API design mode;

[0019] The variable value and variable type corresponding to the first target variable are filled into the preset request template to generate a parsing result request corresponding to the request to be parsed.

[0020] In an optional implementation, the parsing template definition is stored as a structured file, and before the data source based on the first target variable obtains the variable value corresponding to the first target variable from the request to be parsed, it also includes:

[0021] Syntax parsing is performed on the parsing template definition corresponding to the first API to obtain a data source of a first target variable corresponding to the first API and a variable type of the first target variable.

[0022] In an optional implementation, the request to be parsed is an HTTP request, and the data source of the first target variable includes query information carried by the uniform resource locator URL in the HTTP request, request header information, cookie information, body structure or preset interface information.

[0023] In an optional implementation, the first API design pattern is a RESTful architecture pattern, and the second API design pattern is a GraphQL architecture pattern.

[0024] In a second aspect, the present disclosure provides a request processing system, the system comprising:

[0025] The system includes a client, a server and a request parsing engine, wherein the client is generated based on a first API design pattern, and the server is generated based on a second API design pattern;

[0026] The client is used to send the request to be parsed to the request parsing engine through a first application program interface API; wherein the first API is generated based on the first API design pattern;

[0027] The request parsing engine is used to determine the parsing template definition corresponding to the first API, parse the parsing template definition to obtain the data source and variable type of the first target variable corresponding to the first API, obtain the variable value corresponding to the first target variable from the request to be parsed based on the data source of the first target variable, and construct a parsing result request corresponding to the request to be parsed based on the variable value and variable type corresponding to the first target variable, and send the parsing result request to the preset API of the server; wherein the preset API is generated based on the second API design pattern;

[0028] The server is used to process the analysis result request.

[0029] In a third aspect, the present disclosure provides a request processing device, the device comprising:

[0030] A receiving module, configured to receive a request to be parsed from a first application program interface (API); wherein the first API is generated based on a first API design pattern;

[0031] A determination module, configured to determine a parsing template definition corresponding to the first API; wherein the parsing template definition is determined based on a second API design pattern, and the parsing template definition defines a data source of a first target variable corresponding to the first API and a variable type of the first target variable, and the first target variable is used to construct a parsing result request corresponding to the request to be parsed;

[0032] an acquisition module, configured to acquire a variable value corresponding to the first target variable from the request to be parsed based on a data source of the first target variable;

[0033] A construction module is used to construct a parsing result request corresponding to the request to be parsed based on the variable value and variable type corresponding to the first target variable, and send the parsing result request to a preset API; wherein the preset API is generated based on the second API design pattern.

[0034] In a fourth aspect, the present disclosure provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device implements the above method.

[0035] In a fifth aspect, the present disclosure provides a device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the above method is implemented when the processor executes the computer program.

[0036] In a sixth aspect, the present disclosure provides a computer program product, wherein the computer program product comprises a computer program / instructions, and the computer program / instructions implement the above method when executed by a processor.

[0037] Compared with the prior art, the technical solution provided by the embodiment of the present disclosure has at least the following advantages: receiving a request to be parsed from a first application program interface API; wherein the first API is generated based on a first API design pattern, determining a parsing template definition corresponding to the first API; wherein the parsing template definition is determined based on a second API design pattern, and the data source of the first target variable corresponding to the first API and the variable type of the first target variable are defined in the parsing template definition, the first target variable is used to construct a parsing result request corresponding to the request to be parsed, based on the data source of the first target variable, the variable value corresponding to the first target variable is obtained from the request to be parsed, based on the variable value and variable type corresponding to the first target variable, a parsing result request corresponding to the request to be parsed is constructed, and the parsing result request is sent to a preset API; wherein the preset API is generated based on a second API design pattern. The present disclosure parses the request to be parsed from the first API into a parsing result request recognizable by the preset API, so that the front-end and back-end of the same business system can be implemented based on different API design patterns. Therefore, compared with the prior art that completely migrates the front-end and back-end to a software architecture that supports GraphQL, the present disclosure supports only modifying part of the architecture of the business system (such as the back-end), and may not affect the function of the business system, thereby reducing the resulting modification cost. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0039] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0040] Figure 1 A schematic diagram of the structure of a request processing system provided by an embodiment of the present disclosure;

[0041] Figure 2 A schematic diagram of a request processing system implementation process provided by an embodiment of the present disclosure;

[0042] Figure 3 A flowchart of a request processing method provided by an embodiment of the present disclosure;

[0043] Figure 4 A flowchart of another request processing method provided by an embodiment of the present disclosure;

[0044] Figure 5 A schematic diagram of the structure of a request processing device provided in an embodiment of the present disclosure;

[0045] Figure 6 A schematic diagram of the structure of a request processing device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0046] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.

[0047] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0048] REST is a design style and development method for network applications. The RESTful API encapsulated based on REST makes it very easy to separate the front-end and back-end and interact with data, so RESTful API has become a popular software architecture design pattern in the Internet field.

[0049] However, since the data required by different business scenarios on the front end may be similar but also have some differences, and based on the development characteristics of RESTful API, different RESTful APIs need to be developed to meet the needs of the front end in the face of the above business scenarios, which increases the workload of developers. Therefore, there is often a need to transform business systems developed based on RESTful API. Currently, GraphQL provides a more effective, powerful and flexible alternative to REST.

[0050] In the related technology, there is a transformation plan in which the front-end and back-end are completely migrated to a software architecture that supports GraphQL (Graph Query Language), and all interfaces use GraphQL API, but the resulting transformation cost is relatively high.

[0051] To this end, the present disclosure provides a request processing method, receiving a request to be parsed from a first application program interface API; wherein the first API is generated based on a first API design pattern, and a parsing template definition corresponding to the first API is determined; wherein the parsing template definition is determined based on a second API design pattern, and the data source of the first target variable corresponding to the first API and the variable type of the first target variable are defined in the parsing template definition, the first target variable is used to construct a parsing result request corresponding to the request to be parsed, based on the data source of the first target variable, the variable value corresponding to the first target variable is obtained from the request to be parsed, based on the variable value and variable type corresponding to the first target variable, a parsing result request corresponding to the request to be parsed is constructed, and the parsing result request is sent to a preset API; wherein the preset API is generated based on a second API design pattern. The present disclosure parses the request to be parsed from the first API into a parsing result request recognizable by the preset API, so that the front-end and back-end of the same business system can be implemented based on different API design patterns. Therefore, compared with the prior art that completely migrates the front-end and back-end to a software architecture that supports GraphQL, the present disclosure supports only transforming part of the architecture of the business system (such as the back-end), and may not affect the function of the business system, thereby reducing the resulting transformation cost.

[0052] To facilitate the understanding of the overall solution, the present disclosure first introduces a request processing system. Specifically, the request processing system (also referred to as the above-mentioned business system) includes a client, a server, and a request parsing engine. Figure 1 , which is a structural diagram of a request processing system provided in an embodiment of the present disclosure.

[0053] The request processing system 100 includes a client 101, a request parsing engine 102 and a server 103. The client 101 is connected to the request parsing engine 102 through communication, and the request parsing engine 102 is connected to the server 103 through communication.

[0054] Specifically, the client 101 is used to send the request to be parsed to the request parsing engine through the first application program interface API; wherein the client is generated based on the first API design pattern, and the first API is generated based on the first API design pattern.

[0055] The client 101 may be a mobile terminal such as a smart phone, a personal digital assistant (PDA), a tablet personal computer (Tablet PC), a PMP (portable multimedia player), a vehicle terminal (such as a vehicle navigation terminal), a wearable device, a laptop computer, etc., as well as a fixed terminal such as a digital television, a desktop computer, a smart home device, etc.

[0056] The request parsing engine 102 is used to determine the parsing template definition corresponding to the first API, parse the data source and variable type of the first target variable corresponding to the first API from the parsing template definition, obtain the variable value corresponding to the first target variable from the request to be parsed based on the data source of the first target variable, and construct a parsing result request corresponding to the request to be parsed based on the variable value and variable type corresponding to the first target variable, and send the parsing result request to the preset API of the server; wherein the preset API is generated based on the second API design pattern.

[0057] The server 103 is used to process the parsing result request; wherein the server is generated based on the second API design pattern.

[0058] The server 103 may be a laptop computer, a desktop computer, a server or a server cluster, etc.

[0059] For ease of understanding, an example is given in which the first API is a first RESTful API and the preset API is a GraphQL API.

[0060] In an embodiment of the present disclosure, the client sends a request to be parsed, such as a HTTP (HyperText Transfer Protocol) request to be parsed, to a request parsing engine through a first RESTful API.

[0061] After receiving the HTTP request to be parsed sent by the client, the request parsing engine determines the parsing template definition corresponding to the first RESTful API, parses the data source and variable type of the first target variable corresponding to the first RESTful API from the parsing template definition, obtains the variable value corresponding to the first target variable from the HTTP request to be parsed based on the data source of the first target variable, and constructs a parsing result request corresponding to the HTTP request to be parsed based on the variable value and variable type corresponding to the first target variable, and sends the parsing result request to the GraphQL API on the server.

[0062] After receiving the analysis result request sent by the analysis engine, the server processes the analysis result request.

[0063] In order to more clearly understand the request processing system provided by the embodiment of the present disclosure, refer to Figure 2 , which is a schematic diagram of a request processing system implementation process provided by an embodiment of the present disclosure, such as Figure 2As shown, the request to be parsed may come from / api / book of the first RESTful API, from / api / author of the second RESTful API, or from / api / user of the third RESTful API. Taking / api / book of the first RESTful API as an example, the client sends / api / book of the first RESTful API to the request parsing engine. After receiving / api / book of the first RESTful API, the request parsing engine first determines the parsing template definition corresponding to / api / book of the first RESTful API, parses the data source and variable type of the first target variable corresponding to the first RESTful API from the parsing template definition, obtains the variable value corresponding to the first target variable from the request to be parsed based on the data source of the first target variable, constructs a parsing result request corresponding to the request to be parsed based on the variable value and variable type corresponding to the first target variable, and sends the parsing result request to the GraphQL API on the server side.

[0064] In the request processing system provided by the embodiment of the present disclosure, based on the request parsing engine, the request to be parsed from the first RESTful API is parsed into a parsing result request that can be recognized by the GraphQL API, thereby realizing the ability of the client to use the first RESTful API and the corresponding server to use the GraphQL API, reducing the transformation cost problem caused by the client replacing the first RESTful API, and at the same time reducing the workload of server developers.

[0065] Based on this, the present disclosure provides a request processing method, referring to Figure 3 , is a flowchart of a request processing method provided by an embodiment of the present disclosure, the method comprising:

[0066] S301: Receive a request to be parsed from a first application programming interface (API).

[0067] The first API is generated based on a first API design pattern. For example, the first API may be a first RESTful API, and the first RESTful API is designed based on a RESTful architecture pattern.

[0068] The RESTful architecture complies with the constraints and principles of REST and is used to implement the state transformation of the presentation layer of resources. Specifically, each URI (Uniform Resource Identifier) ​​represents a resource. Based on the client's HTTP request, the server's resources are operated to implement the state transformation of the presentation layer. For example, when the client makes a Delete request in the HTTP request, it means deleting the resource from the server.

[0069] The request to be parsed refers to the request information sent by the client. Taking the HTTP request as an example, the HTTP request includes the query information carried by the URL (Uniform Resource Locator), the request header information, the Cookie information, the Body structure or the preset interface information. The preset interface information refers to the information contained in other requests and has an indirect correspondence with the HTTP request.

[0070] Specifically, refer to Figure 4 , which is a flowchart of another request processing method provided by an embodiment of the present disclosure, such as Figure 4 As shown, taking the HTTP request to be parsed of the first RESTful API as an example, / api / doubler?num=50 comes from the Query information carried by the URL, Header: "UserName=seven" comes from the Header information Cookie: "Token=abc123" comes from the Cookie information, and Session: "AppID=13" comes from the preset interface information.

[0071] S302: Determine a parsing template definition corresponding to the first API.

[0072] Among them, the parsing template definition is determined based on the second API design pattern, and the data source of the first target variable corresponding to the first API and the variable type of the first target variable are defined in the parsing template definition. The first target variable is used to construct a parsing result request corresponding to the request to be parsed.

[0073] Specifically, taking the second AIP as GraphQL API as an example, the parsing template is defined based on the GraphQL API design pattern, and the GraphQL API design pattern is the GraphQL architecture pattern. Specifically, the GraphQL architecture is declarative data acquisition, and accurate data return is achieved through an interface. For example, when the client needs to request a user ID, the user ID is accurately returned based on the GraphQL API server.

[0074] Continue to refer Figure 4Taking the first AIP as the first RESTful API as an example, after receiving the HTTP request to be parsed sent by the first RESTful API, the request parsing engine entry determines the parsing template definition corresponding to the first RESTful API. The parsing template definition defines the data source and variable type of the first target variable corresponding to the first RESTful API. Taking the first target variable as a Token variable as an example, the parsing template defines the data source of the Token as Header information, and the data type of the Token is Int.

[0075] In an optional implementation, the parsing template definition may be stored as a structured file such as a JSON file. By parsing the parsing template definition corresponding to the first API, the data source of the first target variable corresponding to the first API and the variable type of the first target variable are obtained. Figure 4 , as shown below, is the JSON file that defines the parsing template corresponding to the first RESTful API:

[0076] {

[0077] "token": "{{ Header.Token}}",

[0078] "num": "{{ Query.num % 100}}",

[0079] "userName": "{{ Header.UserName}}",

[0080] "appID": "{{ Session.AppID}}"

[0081] };

[0082] The JSON file stores the variable source of the first target variable. Taking the AppID variable as an example, the variable source of the AppID variable is Session. Based on the GraphQL schema, the variable type of the AppID variable is Int.

[0083] S303: Based on the data source of the first target variable, obtain a variable value corresponding to the first target variable from the request to be parsed.

[0084] Among them, the data source of the first target variable includes the query information carried by the uniform resource locator URL in the HTTP request, the request header information, the Cookie information, the Body structure or the preset interface information. The preset interface information refers to the information contained in other requests and has an indirect correspondence with the HTTP request.

[0085] In the embodiment of the present disclosure, after obtaining the data source of the first target variable corresponding to the first API in the parsing template definition, the variable value corresponding to the first target variable is obtained from the request to be parsed of the first API, and then referring to Figure 4 Taking the first target variable as the UserName variable as an example, after obtaining the data source of the UserName variable as the Header information, based on the Header information, the variable value seven of the UserName variable is obtained from the request to be parsed of the first API.

[0086] S304: Based on the variable value and variable type corresponding to the first target variable, construct a parsing result request corresponding to the request to be parsed, and send the parsing result request to a preset API.

[0087] The preset API is generated based on the second API design pattern. Specifically, the preset API can be set according to the business scenario, for example, it can be a GraphQL API, and the GraphQL API is generated based on the GraphQL API design pattern.

[0088] In an optional implementation, a preset request template is obtained, and the variable value and variable type corresponding to the first target variable are filled into the preset request template to generate a parsing result request corresponding to the request to be parsed.

[0089] Among them, the preset request template is set based on the second API design mode. Taking the second API as GraphQL as an example, the preset request template is a pre-set template for constructing a template for a GraphQL request.

[0090] In the embodiments of the present disclosure, continue to refer to Figure 4 After determining the variable value and variable type corresponding to the first target variable, obtain the preset request template, fill the variable value and variable type corresponding to the first target variable into the preset request template, and generate a parsing result request corresponding to the request to be parsed, refer to Figure 4 , taking the first target variable as the AppID variable as an example, after determining that the variable value of the AppID variable is 13 and the variable type is Int, it is input into the preset request template to generate a parsing result request, and then the parsing request is sent to the GraphQL API.

[0091] In the request processing method provided in the embodiment of the present disclosure, a request to be parsed from a first application program interface API is received; wherein the first API is generated based on the first API design pattern, and a parsing template definition corresponding to the first API is determined; wherein the parsing template definition is determined based on the second API design pattern, and the data source of the first target variable corresponding to the first API and the variable type of the first target variable are defined in the parsing template definition, the first target variable is used to construct a parsing result request corresponding to the request to be parsed, based on the data source of the first target variable, the variable value corresponding to the first target variable is obtained from the request to be parsed, based on the variable value and variable type corresponding to the first target variable, a parsing result request corresponding to the request to be parsed is constructed, and the parsing result request is sent to a preset API; wherein the preset API is generated based on the second API design pattern. The present disclosure parses the request to be parsed from the first RESTful API into a parsing result request recognizable by the GraphQL API based on the request parsing engine, realizes the ability of the client to use the first RESTful API and the corresponding server to use the GraphQL API, reduces the transformation cost problem caused by the client replacing the first RESTful API, and reduces the workload of the server developers.

[0092] In some embodiments of the present disclosure, the parsing template definition also defines an expression of a second target variable corresponding to the first API, a data source of the intermediate variable contained in the expression, and a variable type of the second target variable. The second target variable is used to construct a parsing result request corresponding to the request to be parsed. Based on the data source of the intermediate variable contained in the expression of the second target variable, the variable value corresponding to the intermediate variable is obtained. Based on the variable value and expression corresponding to the intermediate variable, the variable value corresponding to the second target variable is calculated. Based on the variable values ​​and variable types corresponding to the first target variable and the second target variable, respectively, a parsing result request corresponding to the request to be parsed is constructed.

[0093] Continue to refer Figure 4 , taking the second target variable as the num variable as an example, the num variable is in the form of an expression. After receiving the HTTP request to be parsed of the first RESTful API, the data source of the intermediate variable contained in the expression of the num variable is determined based on the parsing template definition, and the variable value corresponding to the intermediate variable is obtained. Then, based on the variable value and expression of the intermediate variable, the variable value corresponding to the num variable is calculated through the logic calculation module, that is, num = 50%100=50. Finally, based on the variable values ​​and variable types corresponding to the first target variables Token, UserName and AppID and the second target variable num, respectively, the parsing result request corresponding to the HTTP request to be parsed of the first RESTful API is constructed, as shown below:

[0094] {

[0095] "token": "abc123",

[0096] "num": "50",

[0097] "userName": "seven",

[0098] "appID": "13"

[0099] }

[0100] It should be noted that, in order to meet the needs of business scenarios, the logic calculation module can also support a for loop process, and the present disclosure does not make any limitation here.

[0101] In the disclosed embodiment, when the second target variable is an expression, based on the data source of the intermediate variable contained in the expression, the variable value corresponding to the intermediate variable is obtained, based on the variable value and the expression corresponding to the intermediate variable, the variable value corresponding to the second target variable is calculated using a logic calculation module, and then based on the variable value and the variable type corresponding to the second target variable, a parsing result request corresponding to the request to be parsed is constructed, thereby realizing the conversion between the request to be parsed and the parsing result request when the second target variable contained in the request to be parsed is an expression.

[0102] Based on the above method embodiment, the present disclosure also provides a request processing device, referring to Figure 5 , is a schematic diagram of a structure of a request processing device provided by an embodiment of the present disclosure, the device comprising:

[0103] The receiving module 501 is used to receive a request to be parsed from a first application program interface API; wherein the first API is generated based on a first API design pattern;

[0104] A determination module 502 is used to determine a parsing template definition corresponding to the first API; wherein the parsing template definition is determined based on a second API design pattern, and the parsing template definition defines a data source of a first target variable corresponding to the first API and a variable type of the first target variable, and the first target variable is used to construct a parsing result request corresponding to the request to be parsed;

[0105] An acquisition module 503 is configured to acquire a variable value corresponding to the first target variable from the request to be parsed based on a data source of the first target variable;

[0106] The construction module 504 is used to construct a parsing result request corresponding to the request to be parsed based on the variable value and variable type corresponding to the first target variable, and send the parsing result request to a preset API; wherein the preset API is generated based on the second API design pattern.

[0107] In an optional implementation manner, the parsing template definition further defines an expression of a second target variable corresponding to the first API, a data source of an intermediate variable included in the expression, and a variable type of the second target variable, and the second target variable is used to construct a parsing result request corresponding to the request to be parsed;

[0108] Before the building blocks are described, it also includes:

[0109] A first acquisition submodule, configured to acquire a variable value corresponding to the intermediate variable based on a data source of the intermediate variable contained in the expression of the second target variable;

[0110] a calculation submodule, configured to calculate a variable value corresponding to the second target variable based on the variable value corresponding to the intermediate variable and the expression;

[0111] Accordingly, the building blocks are specifically used for:

[0112] Based on the variable values ​​and variable types respectively corresponding to the first target variable and the second target variable, a parsing result request corresponding to the request to be parsed is constructed.

[0113] In an optional implementation, the building block includes:

[0114] A second acquisition submodule is used to acquire a preset request template; wherein the preset request template is set based on the second API design mode;

[0115] A generation submodule is used to fill the variable value and variable type corresponding to the first target variable into the preset request template, and generate a parsing result request corresponding to the request to be parsed.

[0116] In an optional implementation manner, the parsing template definition is stored as a structured file, and before the acquisition module, it also includes:

[0117] A parsing module is used to perform syntax parsing on a parsing template definition corresponding to the first API to obtain a data source of a first target variable corresponding to the first API and a variable type of the first target variable.

[0118] In an optional implementation, the request to be parsed is an HTTP request, and the data source of the first target variable includes query information carried by the uniform resource locator URL in the HTTP request, request header information, cookie information, body structure or preset interface information.

[0119] In an optional implementation, the first API design pattern is a RESTful architecture pattern, and the second API design pattern is a GraphQL architecture pattern.

[0120] The request processing device provided by the embodiment of the present disclosure receives a request to be parsed from a first application program interface API; wherein the first API is generated based on a first API design pattern, and a parsing template definition corresponding to the first API is determined; wherein the parsing template definition is determined based on a second API design pattern, and the data source of the first target variable corresponding to the first API and the variable type of the first target variable are defined in the parsing template definition, the first target variable is used to construct a parsing result request corresponding to the request to be parsed, based on the data source of the first target variable, the variable value corresponding to the first target variable is obtained from the request to be parsed, based on the variable value and variable type corresponding to the first target variable, a parsing result request corresponding to the request to be parsed is constructed, and the parsing result request is sent to a preset API; wherein the preset API is generated based on a second API design pattern. The present disclosure parses the request to be parsed from the first API into a parsing result request recognizable by the preset API, so that the front-end and back-end of the same business system can be implemented based on different API design patterns. Therefore, compared with the prior art that completely migrates the front-end and back-end to a software architecture that supports GraphQL, the present disclosure supports only transforming part of the architecture of the business system (such as the back-end), and may not affect the function of the business system, thereby reducing the resulting transformation cost.

[0121] In addition to the above-mentioned method and apparatus, the embodiments of the present disclosure further provide a computer-readable storage medium, in which instructions are stored. When the instructions are executed on a terminal device, the terminal device implements the request processing method described in the embodiments of the present disclosure.

[0122] The embodiment of the present disclosure further provides a computer program product, which includes a computer program / instructions. When the computer program / instructions are executed by a processor, the request processing method described in the embodiment of the present disclosure is implemented.

[0123] In addition, the present disclosure also provides a request processing device, see Figure 6 As shown, it may include:

[0124] Processor 601, memory 602, input device 603 and output device 604. The number of processors 601 in the request processing device can be one or more. Figure 6 In some embodiments of the present disclosure, the processor 601, the memory 602, the input device 603 and the output device 604 may be connected via a bus or other means, wherein: Figure 6 The example of connecting through bus is taken in the following.

[0125] The memory 602 can be used to store software programs and modules. The processor 601 executes various functional applications and data processing of the request processing device by running the software programs and modules stored in the memory 602. The memory 602 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function, etc. In addition, the memory 602 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. The input device 603 can be used to receive input digital or character information, and generate signal input related to user settings and function control of the request processing device.

[0126] Specifically in this embodiment, the processor 601 will load the executable files corresponding to the processes of one or more applications into the memory 602 according to the following instructions, and the processor 601 will run the applications stored in the memory 602, thereby realizing the various functions of the above-mentioned request processing device.

[0127] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0128] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A request processing method, characterized in that: The method comprises: Receiving a request to be parsed from a first API; wherein the first API is generated based on a first API design pattern; Determine a parsing template definition corresponding to the first API; wherein the parsing template definition is determined based on the second API design pattern, and the data source of the first target variable corresponding to the first API and the variable type of the first target variable are defined in the parsing template definition, the first target variable is used to construct a parsing result request corresponding to the request to be parsed, and the data source of the first target variable and the variable type of the first target variable are parsed from the parsing template definition; Based on the data source of the first target variable, obtaining a variable value corresponding to the first target variable from the request to be parsed; Based on the variable value and variable type corresponding to the first target variable, a parsing result request corresponding to the request to be parsed is constructed, and the parsing result request is sent to a preset API; wherein the preset API is generated based on the second API design pattern.

2. The method according to claim 1, characterized in that The parsing template definition also defines an expression of a second target variable corresponding to the first API, a data source of an intermediate variable contained in the expression, and a variable type of the second target variable, wherein the second target variable is used to construct a parsing result request corresponding to the request to be parsed; Before constructing the parsing result request corresponding to the request to be parsed based on the variable value and variable type corresponding to the first target variable, the method further includes: Based on the data source of the intermediate variable contained in the expression of the second target variable, obtaining a variable value corresponding to the intermediate variable; Calculate the variable value corresponding to the second target variable based on the variable value corresponding to the intermediate variable and the expression; Correspondingly, constructing a parsing result request corresponding to the request to be parsed based on the variable value and variable type corresponding to the first target variable includes: Based on the variable values ​​and variable types respectively corresponding to the first target variable and the second target variable, a parsing result request corresponding to the request to be parsed is constructed.

3. The method according to claim 1, characterized in that The constructing a parsing result request corresponding to the request to be parsed based on the variable value and the variable type corresponding to the first target variable includes: Obtain a preset request template; wherein the preset request template is set based on the second API design mode; The variable value and variable type corresponding to the first target variable are filled into the preset request template to generate a parsing result request corresponding to the request to be parsed.

4. The method according to claim 1, characterized in that: The parsing template definition is stored as a structured file. Before the data source based on the first target variable obtains the variable value corresponding to the first target variable from the request to be parsed, the method further includes: Syntax parsing is performed on the parsing template definition corresponding to the first API to obtain a data source of a first target variable corresponding to the first API and a variable type of the first target variable.

5. The method according to claim 1, characterized in that The request to be parsed is an HTTP request, and the data source of the first target variable includes query information carried by the uniform resource locator URL in the HTTP request, request header information, cookie information, body structure or preset interface information.

6. The method according to claim 1, characterized in that The first API design pattern is a RESTful architecture pattern, and the second API design pattern is a GraphQL architecture pattern.

7. A request processing system, characterized in that: The system includes a client, a server and a request parsing engine, wherein the client is generated based on a first API design pattern, and the server is generated based on a second API design pattern; The client is used to send the request to be parsed to the request parsing engine through a first API; wherein the first API is generated based on the first API design pattern; The request parsing engine is used to determine the parsing template definition corresponding to the first API, parse the parsing template definition to obtain the data source and variable type of the first target variable corresponding to the first API, obtain the variable value corresponding to the first target variable from the request to be parsed based on the data source of the first target variable, and construct a parsing result request corresponding to the request to be parsed based on the variable value and variable type corresponding to the first target variable, and send the parsing result request to the preset API of the server; wherein the preset API is generated based on the second API design pattern, and the parsing template definition is determined based on the second API design pattern; The server is used to process the analysis result request.

8. A request processing device, characterized in that: The device comprises: A receiving module, configured to receive a request to be parsed from a first API; wherein the first API is generated based on a first API design pattern; a determination module, configured to determine a parsing template definition corresponding to the first API; wherein the parsing template definition is determined based on a second API design pattern, the parsing template definition defines a data source of a first target variable corresponding to the first API and a variable type of the first target variable, the first target variable is used to construct a parsing result request corresponding to the request to be parsed, and the data source of the first target variable and the variable type of the first target variable are parsed from the parsing template definition; an acquisition module, configured to acquire a variable value corresponding to the first target variable from the request to be parsed based on a data source of the first target variable; A construction module is used to construct a parsing result request corresponding to the request to be parsed based on the variable value and variable type corresponding to the first target variable, and send the parsing result request to a preset API; wherein the preset API is generated based on the second API design pattern.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device implements the method according to any one of claims 1 to 6.

10. A request processing device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method according to any one of claims 1 to 6 is implemented.

11. A computer program product, characterized in that The computer program product comprises a computer program / instruction, and when the computer program / instruction is executed by a processor, the method according to any one of claims 1 to 6 is implemented.