CN114816403A - Request processing method, device, equipment and storage medium - Google Patents

Request processing method, device, equipment and storage medium Download PDF

Info

Publication number
CN114816403A
CN114816403A CN202210411950.8A CN202210411950A CN114816403A CN 114816403 A CN114816403 A CN 114816403A CN 202210411950 A CN202210411950 A CN 202210411950A CN 114816403 A CN114816403 A CN 114816403A
Authority
CN
China
Prior art keywords
request
api
variable
target variable
analyzed
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210411950.8A
Other languages
Chinese (zh)
Inventor
贺长鸿
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202210411950.8A priority Critical patent/CN114816403A/en
Publication of CN114816403A publication Critical patent/CN114816403A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/427Parsing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Human Computer Interaction (AREA)
  • Stored Programmes (AREA)

Abstract

The present disclosure provides a request processing method, apparatus, device and storage medium, wherein the method comprises: the method comprises the steps of receiving a request to be analyzed from a first Application Program Interface (API), determining an analysis template definition corresponding to the first API, acquiring a variable value corresponding to a first target variable from the request to be analyzed based on a data source of the first target variable, constructing an analysis result request corresponding to the request to be analyzed based on the variable value and the variable type corresponding to the first target variable, and sending the analysis result request to a preset API. According to the method and the device, the request to be analyzed from the first API is analyzed into the analysis result request which can be identified by the preset API, compared with the prior art that the front end and the back end are completely migrated to the software architecture supporting the GraphQL, the method and the device support only partial architecture (such as the back end) of the business system to be modified, the function of the business system can not be influenced, and the modification cost is reduced.

Description

Request processing method, device, equipment and storage medium
Technical Field
The present disclosure relates to the field of data processing, and in particular, to a request processing method, apparatus, device, and storage medium.
Background
REST (Representational State Transfer) is a design style and development mode of a network Application program, and RESTful API (Application Programming interface) obtained based on REST encapsulation makes separation of front and back ends and data interaction very easy, so the RESTful API becomes a popular software architecture design mode in the Internet field.
However, because data required by different business scenarios at the front end may be similar but have some differences, based on the development characteristics of the RESTful API, different RESTful APIs need to be developed to meet the requirements of the front end in the face of the business scenarios, and the workload of developers is increased. Therefore, there is often a need for retrofitting business systems developed based on RESTful APIs, and GraphQL currently provides a more efficient, powerful, and flexible alternative to REST.
In the related art, a software architecture for completely migrating the front end and the back end to support Graph ql (Graph Query Language) exists, and all interfaces use a modification scheme of a Graph ql API, but the modification cost generated by the modification scheme is large.
Disclosure of Invention
In order to solve the above technical problem, an embodiment of the present disclosure provides a request processing method.
In a first aspect, the present disclosure provides a request processing method, including:
receiving a request to be analyzed from a first Application Program Interface (API); wherein the first API is generated based on a first API design mode;
determining an analysis template definition corresponding to the first API; the analysis template definition is determined based on a second API design mode, a data source of a first target variable corresponding to the first API and a variable type of the first target variable are defined in the analysis template definition, and the first target variable is used for constructing an analysis result request corresponding to the request to be analyzed;
acquiring a variable value corresponding to the first target variable from the request to be analyzed based on the data source of the first target variable;
constructing an analysis result request corresponding to the request to be analyzed based on the variable value and the variable type corresponding to the first target variable, and sending the analysis result request to a preset API; and the preset API is generated based on the second API design mode.
In an optional implementation manner, 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 are further defined in the definition of the parsing template, where the second target variable is used to construct a parsing result request corresponding to the request to be parsed;
before constructing the analysis result request corresponding to the request to be analyzed based on the variable value and the variable type corresponding to the first target variable, the method further includes:
acquiring a variable value corresponding to an intermediate variable based on a data source of the intermediate variable contained in the expression of the second target variable;
calculating a variable value corresponding to the second target variable based on the variable value corresponding to the intermediate variable and the expression;
correspondingly, the constructing an analysis result request corresponding to the request to be analyzed based on the variable value and the variable type corresponding to the first target variable includes:
and constructing an analysis result request corresponding to the request to be analyzed based on the variable value and the variable type respectively corresponding to the first target variable and the second target variable.
In an optional implementation manner, 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:
acquiring a preset request template; the preset request template is set based on the second API design mode;
and filling the variable value and the variable type corresponding to the first target variable into the preset request template to generate an analysis result request corresponding to the request to be analyzed.
In an optional implementation manner, the parsing template definition is stored as a structured file, and before the obtaining, from the request to be parsed, a variable value corresponding to the first target variable based on the data source of the first target variable, the parsing template definition further includes:
and carrying out syntax analysis on the analysis 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.
In an optional implementation manner, the request to be analyzed belongs to an HTTP request, and the data source of the first target variable includes Query information, request Header information, Cookie information, a Body structure, or preset interface information carried by a uniform resource locator URL in the HTTP request.
In an optional embodiment, the first API design mode is a RESTful architecture mode, and the second API design mode is a GraphQL architecture mode.
In a second aspect, the present disclosure provides a request processing system, the system comprising:
the system comprises a client, a server and a request analysis engine, wherein the client is generated based on a first API design mode, and the server is generated based on a second API design mode;
the client is used for sending a request to be analyzed to the request analysis engine through a first Application Program Interface (API); wherein the first API is generated based on the first API design pattern;
the request analysis engine is used for determining an analysis template definition corresponding to the first API, analyzing the analysis template definition to obtain a data source and a variable type of a first target variable corresponding to the first API, acquiring a variable value corresponding to the first target variable from the request to be analyzed based on the data source of the first target variable, constructing an analysis result request corresponding to the request to be analyzed based on the variable value and the variable type corresponding to the first target variable, and sending the analysis result request to a preset API of the server; the preset API is generated based on the second API design mode;
and the server is used for processing the analysis result request.
In a third aspect, the present disclosure provides a request processing apparatus, the apparatus comprising:
the receiving module is used for receiving a request to be analyzed from a first Application Program Interface (API); wherein the first API is generated based on a first API design mode;
the determining module is used for determining the definition of the analysis template corresponding to the first API; the analysis template definition is determined based on a second API design mode, a data source of a first target variable corresponding to the first API and a variable type of the first target variable are defined in the analysis template definition, and the first target variable is used for constructing an analysis result request corresponding to the request to be analyzed;
the acquisition module is used for acquiring a variable value corresponding to the first target variable from the request to be analyzed based on the data source of the first target variable;
the construction module is used for constructing an analysis result request corresponding to the request to be analyzed based on the variable value and the variable type corresponding to the first target variable, and sending the analysis result request to a preset API; and the preset API is generated based on the second API design mode.
In a fourth aspect, the present disclosure provides a computer-readable storage medium having stored therein instructions that, when run on a terminal device, cause the terminal device to implement the method described above.
In a fifth aspect, the present disclosure provides an apparatus comprising: the system comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor executes the computer program to realize the method.
In a sixth aspect, the present disclosure provides a computer program product comprising computer programs/instructions which, when executed by a processor, implement the method described above.
Compared with the prior art, the technical scheme provided by the embodiment of the disclosure has at least the following advantages: receiving a request to be analyzed from a first Application Program Interface (API); the first API is generated based on a first API design mode, and an analysis template definition corresponding to the first API is determined; the analysis template definition is determined based on a second API design mode, a data source of a first target variable corresponding to a first API and a variable type of the first target variable are defined in the analysis template definition, the first target variable is used for constructing an analysis result request corresponding to a request to be analyzed, a variable value corresponding to the first target variable is obtained from the request to be analyzed based on the data source of the first target variable, an analysis result request corresponding to the request to be analyzed is constructed based on the variable value and the variable type corresponding to the first target variable, and the analysis result request is sent to a preset API; and the preset API is generated based on the second API design mode. According to the method, the front end and the back end of the same service system can be realized based on different API design modes by analyzing the request to be analyzed from the first API into the analysis result request which can be identified by the preset API, so that compared with the prior art that the front end and the back end are completely migrated to the software architecture supporting GraphQL, the method only modifies partial architecture (such as the back end) of the service system, does not influence the function of the service system, and reduces the modification cost.
Drawings
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 disclosure.
In order to more clearly illustrate the embodiments or technical solutions in the prior art of the present disclosure, the drawings used in the description of the embodiments or prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
Fig. 1 is a schematic structural diagram of a request processing system according to an embodiment of the present disclosure;
FIG. 2 is a schematic diagram of a request processing system implementation process provided by an embodiment of the present disclosure;
fig. 3 is a flowchart of a request processing method provided by an embodiment of the present disclosure;
FIG. 4 is a flow chart of another request processing method provided by the embodiments of the present disclosure;
fig. 5 is a schematic structural diagram of a request processing apparatus according to an embodiment of the present disclosure;
fig. 6 is a schematic structural diagram of a request processing device according to an embodiment of the present disclosure.
Detailed Description
In order that the above objects, features and advantages of the present disclosure may be more clearly understood, aspects of the present disclosure will be further described below. It should be noted that the embodiments and features of the embodiments of the present disclosure may be combined with each other without conflict.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present disclosure, but the present disclosure may be practiced in other ways than those described herein; it is to be understood that the embodiments disclosed in the specification are only a few embodiments of the present disclosure, and not all embodiments.
REST is a design style and a development mode of a network application program, and a RESTful API obtained based on REST encapsulation enables front-end and back-end separation and data interaction to be very easy, so the RESTful API becomes a popular software architecture design mode in the Internet field.
However, because data required by different business scenarios at the front end may be similar but have some differences, based on the development characteristics of the RESTful API, different RESTful APIs need to be developed to meet the requirements of the front end in the face of the business scenarios, and the workload of developers is increased. Therefore, there is often a need for retrofitting business systems developed based on RESTful APIs, and GraphQL currently provides a more efficient, powerful, and flexible alternative to REST.
In the related art, a software architecture for completely migrating the front end and the back end to support Graph ql (Graph Query Language) exists, and all interfaces use a modification scheme of a Graph ql API, but the modification cost generated by the modification scheme is large.
Therefore, the disclosure provides a request processing method, which receives a request to be analyzed from a first Application Program Interface (API); the first API is generated based on a first API design mode, and an analysis template definition corresponding to the first API is determined; the analysis template definition is determined based on a second API design mode, a data source of a first target variable corresponding to a first API and a variable type of the first target variable are defined in the analysis template definition, the first target variable is used for constructing an analysis result request corresponding to a request to be analyzed, a variable value corresponding to the first target variable is obtained from the request to be analyzed based on the data source of the first target variable, an analysis result request corresponding to the request to be analyzed is constructed based on the variable value and the variable type corresponding to the first target variable, and the analysis result request is sent to a preset API; and the preset API is generated based on the second API design mode. According to the method, the front end and the back end of the same service system can be realized based on different API design modes by analyzing the request to be analyzed from the first API into the analysis result request which can be identified by the preset API, so that compared with the prior art that the front end and the back end are completely migrated to the software architecture supporting GraphQL, the method only modifies partial architecture (such as the back end) of the service system, does not influence the function of the service system, and reduces the modification cost.
To facilitate understanding of the overall scheme, the present disclosure first introduces a request processing system, specifically, the request processing system (also referred to as the business system) includes a client, a server, and a request parsing engine, and referring to fig. 1, a schematic structural diagram of a request processing system provided for an embodiment of the present disclosure is provided.
The request processing system 100 includes a client 101, a request parsing engine 102 and a server 103, where the client 100 is connected to the request parsing engine 102 through communication, and the request parsing engine 102 is connected to the server 103 through communication.
Specifically, the client 101 is configured to send a request to be parsed to a request parsing engine through a first application program interface API; the client side is generated based on a first API design mode, and the first API is generated based on the first API design mode.
The client 101 may be a smart phone, a Personal Digital Assistant (PDA), a Tablet PC, a PMP, a mobile terminal (e.g., a car navigation terminal), a wearable device, a notebook Computer, etc., and a fixed terminal such as a Digital television, a desktop Computer, a smart home device, etc.
The request analysis engine 102 is configured to determine an analysis template definition corresponding to the first API, analyze the analysis template definition to obtain a data source and a variable type of a first target variable corresponding to the first API, obtain a variable value corresponding to the first target variable from the request to be analyzed based on the data source of the first target variable, construct an analysis result request corresponding to the request to be analyzed based on the variable value and the variable type corresponding to the first target variable, and send the analysis result request to a preset API of the server; and the preset API is generated based on the second API design mode.
The server 103 is used for processing the analysis result request; and the server side is generated based on the second API design mode.
The server 103 may be a notebook computer, a desktop computer, a server or a server cluster, etc.
For convenience of understanding, the first API is taken as the first RESTful API, and the predetermined API is taken as the GraphQL API.
In the 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 the request parsing engine through the first RESTful API.
The method comprises the steps that after a request analysis engine receives an HTTP request to be analyzed sent by a client, an analysis template definition corresponding to a first RESTful API is determined, a data source and a variable type of a first target variable corresponding to the first RESTful API are obtained through analysis from the analysis template definition, a variable value corresponding to the first target variable is obtained from the HTTP request to be analyzed based on the data source of the first target variable, an analysis result request corresponding to the HTTP request to be analyzed is constructed based on the variable value and the variable type corresponding to the first target variable, and the analysis result request is sent to a GraphQL API of a server.
And after receiving the analysis result request sent by the analysis engine, the server side processes the analysis result request.
In order to more clearly understand the request processing system provided by the embodiment of the present disclosure, referring to fig. 2, a schematic diagram of an implementation process of the request processing system provided by the embodiment of the present disclosure is shown in fig. 2, as shown in fig. 2, a to-be-resolved request may be from/API/book of a first RESTful API, or may be from/API/author of a second RESTful API, or may be from/API/user of a third RESTful API, taking/API/book of the first RESTful API as an example, a client sends/API/book of the first RESTful API to a request resolution engine, the request resolution engine, after receiving/API/book of the first RESTful API, first determines a resolution template definition corresponding to/API/book of the first RESTful API, and obtains a data source and a variable type of a first target variable corresponding to the first RESTful API through resolution from the template definition, and acquiring a variable value corresponding to the first target variable from the request to be analyzed based on the data source of the first target variable, constructing an analysis result request corresponding to the request to be analyzed based on the variable value and the variable type corresponding to the first target variable, and sending the analysis result request to a GraphQL API of the server.
In the request processing system provided by the embodiment of the disclosure, the request to be analyzed from the first RESTful API is analyzed into the analysis result request which can be identified by the GraphQL API based on the request analysis engine, so that the client uses the first RESTful API, the corresponding server uses the GraphQL API, the problem of the transformation cost caused by the replacement of the first RESTful API by the client is reduced, and the workload of the server developer is reduced.
Based on this, the embodiment of the present disclosure provides a request processing method, and referring to fig. 3, is a flowchart of the request processing method provided in the embodiment of the present disclosure, where the method includes:
s301: a request to be parsed is received from a first application program interface API.
Wherein the first API is generated based on a first API design pattern, for example: the first API may be a first RESTful API designed based on a RESTful architectural schema.
The RESTful architecture conforms to constraint conditions and principles of REST, and is used for implementing presentation layer state transformation of resources, specifically, each URI (Uniform Resource Identifier) represents a Resource, and the Resource of the server is operated based on an HTTP request of the client, so as to implement presentation layer state transformation, for example: when the client side is a Delete request in the HTTP request, the resource is deleted from the server side.
The request to be analyzed refers to request information sent by a client, taking an HTTP request as an example, the HTTP request includes Query information, request Header information, Cookie information, Body structure, or preset interface information carried by a URL (Uniform Resource Locator), and the preset interface information refers to information included in other requests and has an indirect correspondence with the HTTP request.
Specifically, referring to fig. 4, a flowchart of another request processing method provided in the embodiment of the present disclosure is shown in fig. 4, where an HTTP request to be analyzed of a first RESTful API is taken as an example, where/API/doublerum ═ 50 is from Query information carried by a URL, Header: "UserName ═ seven" is from Header information Cookie: "Token ═ abc123" is from Cookie information, Session: "AppID 13" comes from the preset interface information.
S302: and determining the definition of the resolution template corresponding to the first API.
The analysis template definition is determined based on a second API design mode, a data source of a first target variable corresponding to a first API and a variable type of the first target variable are defined in the analysis template definition, and the first target variable is used for constructing an analysis result request corresponding to a request to be analyzed.
Specifically, taking the second AIP as a GraphQL API as an example, the parsing template is defined to be determined based on a GraphQL API design mode, the GraphQL API design mode is a GraphQL architecture mode, specifically, the GraphQL architecture is declarative data acquisition, and accurate data return is realized through an interface, for example, when a client needs to request a user ID, accurate user ID return is realized based on the GraphQL API server.
Continuing with reference to fig. 4, taking the first AIP as the first RESTful API as an example, after receiving the HTTP request to be analyzed sent by the first RESTful API, the request analysis engine entry determines an analysis template definition corresponding to the first RESTful API, where the analysis template definition defines a data source and a variable type of a first target variable corresponding to the first RESTful API, and taking the first target variable as a Token variable as an example, the analysis template defines that a data source of Token is Header information, and a data type of Token is Int.
In an optional embodiment, the parsing template definition may be stored as a structured file, such as a JSON file, and syntax parsing is performed on the parsing template definition corresponding to the first API to obtain a data source of the first target variable and a variable type of the first target variable corresponding to the first API, and with reference to fig. 4, the JSON file defined by the parsing template corresponding to the first RESTful API is as follows:
{
"token":"{{Header.Token}}",
"num":"{{Query.num%100}}",
"userName":"{{Header.UserName}}",
"appID":"{{Session.AppID}}"
};
the JSON file stores a variable source of a first target variable, the first target variable is taken as an AppID variable as an example, the variable source of the AppID variable is Session, and meanwhile, the variable type of the AppID variable is Int which is obtained based on schema of GraphQL.
S303: and acquiring a variable value corresponding to the first target variable from the request to be analyzed based on the data source of the first target variable.
The data source of the first target variable comprises Query information, request Header information, Cookie information, a Body structure Body or preset interface information carried by a Uniform Resource Locator (URL) in the HTTP request, wherein the preset interface information refers to information contained in other requests and has an indirect corresponding relation with the HTTP request.
In the embodiment of the present disclosure, after a data source of a first target variable corresponding to a first API is obtained in an analysis template definition, a variable value corresponding to the first target variable is obtained from a request to be analyzed of the first API, with reference to fig. 4, taking the first target variable as a UserName variable as an example, and after the data source of the UserName variable is obtained as Header information, a variable value seven of the UserName variable is obtained from the request to be analyzed of the first API based on the Header information.
S304: and constructing an analysis result request corresponding to the request to be analyzed based on the variable value and the variable type corresponding to the first target variable, and sending the analysis result request to a preset API.
The preset API is generated based on the second API design mode, specifically, the preset API may be set according to a service scenario, for example, the preset API may be a GraphQL API, and the GraphQL API is generated based on the GraphQL API design mode.
In an optional implementation manner, a preset request template is obtained, a variable value and a variable type corresponding to a first target variable are filled in the preset request template, and an analysis result request corresponding to a request to be analyzed is generated.
The preset request template is set based on a second API design mode, taking the second API as the GraphQL as an example, and the preset request template is a preset template and is used for constructing a GraphQL request template.
In this disclosure, with reference to fig. 4, after determining a variable value and a variable type corresponding to a first target variable, obtaining a preset request template, filling the variable value and the variable type corresponding to the first target variable into the preset request template, and generating an analysis result request corresponding to a request to be analyzed, with reference to fig. 4, taking the first target variable as an AppID variable as an example, after determining that the variable value of the AppID variable is 13 and the variable type is Int, inputting the variable into the preset request template, generating an analysis result request, and then sending the analysis request to a GraphQL API.
In the request processing method provided by the embodiment of the disclosure, a request to be analyzed from a first Application Program Interface (API) is received; the first API is generated based on a first API design mode, and an analysis template definition corresponding to the first API is determined; the analysis template definition is determined based on a second API design mode, a data source of a first target variable corresponding to a first API and a variable type of the first target variable are defined in the analysis template definition, the first target variable is used for constructing an analysis result request corresponding to a request to be analyzed, a variable value corresponding to the first target variable is obtained from the request to be analyzed based on the data source of the first target variable, an analysis result request corresponding to the request to be analyzed is constructed based on the variable value and the variable type corresponding to the first target variable, and the analysis result request is sent to a preset API; and the preset API is generated based on the second API design mode. The method and the device have the advantages that the request to be analyzed from the first RESTful API is analyzed into the analysis result request which can be identified by the GraphQL API by the request analysis engine, so that the client uses the first RESTful API, the corresponding server uses the GraphQL API, the problem of the transformation cost caused by the fact that the client replaces the first RESTful API is solved, and meanwhile the workload of server developers is reduced.
In some embodiments of the present disclosure, 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 are further defined in the definition of the parsing template, where the second target variable is used to construct a parsing result request corresponding to the request to be parsed, a variable value corresponding to the intermediate variable is obtained based on the data source of the intermediate variable included in the expression of the second target variable, a variable value corresponding to the second target variable is calculated based on the variable value and the expression corresponding to the intermediate variable, and a parsing result request corresponding to the request to be parsed is constructed based on the variable value and the variable type respectively corresponding to the first target variable and the second target variable.
Continuing with reference to fig. 4, taking a second target variable as a num variable as an example, where the num variable is in an expression form, after receiving an HTTP request to be analyzed of a first RESTful API, determining a data source of an intermediate variable included in an expression of the num variable based on an analysis template definition, and obtaining a variable value corresponding to the intermediate variable, then calculating a variable value corresponding to the num variable through a logic calculation module based on the variable value and the expression of the intermediate variable, where num is 50% and 100% and 50, and finally constructing an analysis result request corresponding to the HTTP request to be analyzed of the first RESTful API based on a variable value and a variable type respectively corresponding to the first target variable Token, UserName, and AppID, and the second target variable num as follows:
{
"token":"abc123",
"num":"50",
"userName":"seven",
"appID":"13"
}
it should be noted that, in order to meet the needs of the service scenario, the logic calculation module may also support a for loop process, and the disclosure is not limited herein.
In the embodiment of the disclosure, when the second target variable is an expression, a variable value corresponding to the intermediate variable is obtained based on a data source of the intermediate variable included in the expression, a variable value corresponding to the second target variable is calculated by using a logic calculation module based on the variable value and the expression corresponding to the intermediate variable, and then an analysis result request corresponding to the request to be analyzed is constructed based on the variable value and the variable type corresponding to the second target variable, so that when the second target variable included in the request to be analyzed is the expression, the request to be analyzed is converted from the analysis result request.
Based on the foregoing method embodiment, the present disclosure further provides a request processing apparatus, and with reference to fig. 5, a schematic structural diagram of the request processing apparatus provided in the embodiment of the present disclosure is shown, where the apparatus includes:
a receiving module 501, configured to receive a request to be analyzed from a first application program interface API; wherein the first API is generated based on a first API design mode;
a determining module 502, configured to determine an analysis template definition corresponding to the first API; the analysis template definition is determined based on a second API design mode, a data source of a first target variable corresponding to the first API and a variable type of the first target variable are defined in the analysis template definition, and the first target variable is used for constructing an analysis result request corresponding to the request to be analyzed;
an obtaining module 503, configured to obtain, based on a data source of the first target variable, a variable value corresponding to the first target variable from the request to be analyzed;
a building module 504, configured to build an analysis result request corresponding to the request to be analyzed based on a variable value and a variable type corresponding to the first target variable, and send the analysis result request to a preset API; and the preset API is generated based on the second API design mode.
In an optional implementation manner, 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 are further defined in the definition of the parsing template, where the second target variable is used to construct a parsing result request corresponding to the request to be parsed;
before the building module, the method further comprises the following steps:
the first obtaining submodule is used for obtaining a variable value corresponding to an intermediate variable based on a data source of the intermediate variable contained in the expression of the second target variable;
the calculation submodule is used for calculating a variable value corresponding to the second target variable based on the variable value corresponding to the intermediate variable and the expression;
correspondingly, the building module is specifically configured to:
and constructing an analysis result request corresponding to the request to be analyzed based on the variable value and the variable type respectively corresponding to the first target variable and the second target variable.
In an alternative embodiment, the building block comprises:
the second obtaining submodule is used for obtaining a preset request template; the preset request template is set based on the second API design mode;
and the generation submodule is used for filling the variable value and the variable type corresponding to the first target variable into the preset request template to generate an analysis result request corresponding to the request to be analyzed.
In an optional embodiment, the parsing template definition is stored as a structured file, and before the obtaining module, the method further includes:
and the analysis module is used for carrying out syntax analysis on the analysis 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.
In an optional implementation manner, the request to be analyzed belongs to an HTTP request, and the data source of the first target variable includes Query information, request Header information, Cookie information, a Body structure, or preset interface information carried by a uniform resource locator URL in the HTTP request.
In an optional embodiment, the first API design mode is a RESTful architecture mode, and the second API design mode is a GraphQL architecture mode.
The request processing device provided by the embodiment of the disclosure receives a request to be analyzed from a first Application Program Interface (API); the first API is generated based on a first API design mode, and an analysis template definition corresponding to the first API is determined; the analysis template definition is determined based on a second API design mode, a data source of a first target variable corresponding to a first API and a variable type of the first target variable are defined in the analysis template definition, the first target variable is used for constructing an analysis result request corresponding to a request to be analyzed, a variable value corresponding to the first target variable is obtained from the request to be analyzed based on the data source of the first target variable, an analysis result request corresponding to the request to be analyzed is constructed based on the variable value and the variable type corresponding to the first target variable, and the analysis result request is sent to a preset API; and the preset API is generated based on the second API design mode. According to the method, the front end and the back end of the same service system can be realized based on different API design modes by analyzing the request to be analyzed from the first API into the analysis result request which can be identified by the preset API, so that compared with the prior art that the front end and the back end are completely migrated to the software architecture supporting GraphQL, the method only modifies partial architecture (such as the back end) of the service system, does not influence the function of the service system, and reduces the modification cost.
In addition to the above method and apparatus, the present disclosure also provides a computer-readable storage medium, where instructions are stored, and when the instructions are executed on a terminal device, the terminal device is caused to implement the request processing method according to the present disclosure.
The disclosed embodiments also provide a computer program product comprising a computer program/instructions, which when executed by a processor implement the request processing method of the disclosed embodiments.
In addition, an embodiment of the present disclosure further provides a request processing device, as shown in fig. 6, which may include:
a processor 601, a memory 602, an input device 603, and an output device 604. The number of processors 601 in the request processing device may be one or more, and one processor is taken as an example in fig. 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 through a bus or other means, wherein the connection through the bus is exemplified in fig. 6.
The memory 602 may be used to store software programs and modules, and the processor 601 executes various functional applications and data processing of the request processing device by operating the software programs and modules stored in the memory 602. The memory 602 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required for at least one function, and the like. Further, the memory 602 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. The input device 603 may be used to receive entered numeric or character information and generate signal inputs relating to user settings and function control of the request processing apparatus.
Specifically, in this embodiment, the processor 601 loads an executable file corresponding to one or more processes of the application program into the memory 602 according to the following instructions, and the processor 601 runs the application program stored in the memory 602, thereby implementing various functions of the request processing device.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The foregoing are merely exemplary embodiments of the present disclosure, which enable those skilled in the art to understand or practice the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the disclosure. Thus, the present disclosure is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (11)

1. A method for processing a request, the method comprising:
receiving a request to be analyzed from a first Application Program Interface (API); wherein the first API is generated based on a first API design mode;
determining an analysis template definition corresponding to the first API; the analysis template definition is determined based on a second API design mode, a data source of a first target variable corresponding to the first API and a variable type of the first target variable are defined in the analysis template definition, and the first target variable is used for constructing an analysis result request corresponding to the request to be analyzed;
acquiring a variable value corresponding to the first target variable from the request to be analyzed based on the data source of the first target variable;
constructing an analysis result request corresponding to the request to be analyzed based on the variable value and the variable type corresponding to the first target variable, and sending the analysis result request to a preset API; and the preset API is generated based on the second API design mode.
2. The method according to claim 1, wherein 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 are further defined in the definition of the parsing template, and the second target variable is used for constructing a parsing result request corresponding to the request to be parsed;
before constructing the analysis result request corresponding to the request to be analyzed based on the variable value and the variable type corresponding to the first target variable, the method further includes:
acquiring a variable value corresponding to an intermediate variable based on a data source of the intermediate variable contained in the expression of the second target variable;
calculating a variable value corresponding to the second target variable based on the variable value corresponding to the intermediate variable and the expression;
correspondingly, the constructing an analysis result request corresponding to the request to be analyzed based on the variable value and the variable type corresponding to the first target variable includes:
and constructing an analysis result request corresponding to the request to be analyzed based on the variable value and the variable type respectively corresponding to the first target variable and the second target variable.
3. The method according to claim 1, wherein constructing the analysis result request corresponding to the request to be analyzed based on the variable value and the variable type corresponding to the first target variable comprises:
acquiring a preset request template; the preset request template is set based on the second API design mode;
and filling the variable value and the variable type corresponding to the first target variable into the preset request template to generate an analysis result request corresponding to the request to be analyzed.
4. The method according to claim 1, wherein the parsing template definition is stored as a structured file, and before obtaining a variable value corresponding to the first target variable from the request to be parsed based on the data source of the first target variable, the method further comprises:
and carrying out syntax analysis on the analysis 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, wherein the request to be resolved belongs to an HTTP request, and the data source of the first target variable includes Query information, request Header information, Cookie information, Body structure, or preset interface information carried by a uniform resource locator URL in the HTTP request.
6. The method of claim 1, wherein the first API design schema is a RESTful architectural schema and the second API design schema is a GraphQL architectural schema.
7. A request processing system is characterized by comprising a client, a server and a request analysis engine, wherein the client is generated based on a first API design mode, and the server is generated based on a second API design mode;
the client is used for sending a request to be analyzed to the request analysis engine through a first Application Program Interface (API); wherein the first API is generated based on the first API design mode;
the request analysis engine is used for determining an analysis template definition corresponding to the first API, analyzing the analysis template definition to obtain a data source and a variable type of a first target variable corresponding to the first API, acquiring a variable value corresponding to the first target variable from the request to be analyzed based on the data source of the first target variable, constructing an analysis result request corresponding to the request to be analyzed based on the variable value and the variable type corresponding to the first target variable, and sending the analysis result request to a preset API of the server; the preset API is generated based on the second API design mode;
and the server is used for processing the analysis result request.
8. A request processing apparatus, characterized in that the apparatus comprises:
the receiving module is used for receiving a request to be analyzed from a first Application Program Interface (API); wherein the first API is generated based on a first API design mode;
the determining module is used for determining the definition of the analysis template corresponding to the first API; the analysis template definition is determined based on a second API design mode, a data source of a first target variable corresponding to the first API and a variable type of the first target variable are defined in the analysis template definition, and the first target variable is used for constructing an analysis result request corresponding to the request to be analyzed;
the acquisition module is used for acquiring a variable value corresponding to the first target variable from the request to be analyzed based on the data source of the first target variable;
the construction module is used for constructing an analysis result request corresponding to the request to be analyzed based on the variable value and the variable type corresponding to the first target variable, and sending the analysis result request to a preset API; and the preset API is generated based on the second API design mode.
9. A computer-readable storage medium having stored therein instructions that, when run on a terminal device, cause the terminal device to implement the method of any one of claims 1-6.
10. A request processing device, comprising: memory, a processor, and a computer program stored on the memory and executable on the processor, when executing the computer program, implementing the method of any of claims 1-6.
11. A computer program product, characterized in that the computer program product comprises a computer program/instructions which, when executed by a processor, implements the method according to any of claims 1-6.
CN202210411950.8A 2022-04-19 2022-04-19 Request processing method, device, equipment and storage medium Pending CN114816403A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210411950.8A CN114816403A (en) 2022-04-19 2022-04-19 Request processing method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210411950.8A CN114816403A (en) 2022-04-19 2022-04-19 Request processing method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114816403A true CN114816403A (en) 2022-07-29

Family

ID=82505854

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210411950.8A Pending CN114816403A (en) 2022-04-19 2022-04-19 Request processing method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114816403A (en)

Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101488070A (en) * 2004-06-25 2009-07-22 苹果公司 User interface element with auxiliary function
CN107948135A (en) * 2017-10-31 2018-04-20 贵州白山云科技有限公司 A kind of data processing method and device for supporting a variety of API protocols
US20190121840A1 (en) * 2017-10-20 2019-04-25 Heretik Inc. Method and system for dynamically configuring a user interface for a specified document review task
US20190196890A1 (en) * 2017-12-22 2019-06-27 MuleSoft, Inc. Api query
US20200151038A1 (en) * 2018-11-13 2020-05-14 American Express Travel Related Services Company, Inc. Automated web service and api build configuration framework
CN111427610A (en) * 2020-03-25 2020-07-17 山东浪潮通软信息科技有限公司 Method, device, equipment and readable medium for integrating third-party services
US10747505B1 (en) * 2019-05-17 2020-08-18 Google Llc API specification generation
CN111865881A (en) * 2019-04-30 2020-10-30 北京数聚鑫云信息技术有限公司 Interface conversion method, device, medium and computer equipment
CN112162873A (en) * 2020-09-28 2021-01-01 杭州安恒信息技术股份有限公司 Remote calling method, electronic device and storage medium
CN112597187A (en) * 2021-03-03 2021-04-02 北京冠新医卫软件科技有限公司 GraphQL query method and device based on FHIR standard
CN113225379A (en) * 2021-03-31 2021-08-06 北京三快在线科技有限公司 Method and device for sending HTTP request message
US20210248143A1 (en) * 2020-02-10 2021-08-12 Citrix Systems, Inc. Automatically executing graphql queries on databases
CN114064690A (en) * 2021-11-17 2022-02-18 中国工商银行股份有限公司 Data processing method and device

Patent Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101488070A (en) * 2004-06-25 2009-07-22 苹果公司 User interface element with auxiliary function
US20190121840A1 (en) * 2017-10-20 2019-04-25 Heretik Inc. Method and system for dynamically configuring a user interface for a specified document review task
CN107948135A (en) * 2017-10-31 2018-04-20 贵州白山云科技有限公司 A kind of data processing method and device for supporting a variety of API protocols
US20190196890A1 (en) * 2017-12-22 2019-06-27 MuleSoft, Inc. Api query
US20200151038A1 (en) * 2018-11-13 2020-05-14 American Express Travel Related Services Company, Inc. Automated web service and api build configuration framework
CN111865881A (en) * 2019-04-30 2020-10-30 北京数聚鑫云信息技术有限公司 Interface conversion method, device, medium and computer equipment
US10747505B1 (en) * 2019-05-17 2020-08-18 Google Llc API specification generation
US20210248143A1 (en) * 2020-02-10 2021-08-12 Citrix Systems, Inc. Automatically executing graphql queries on databases
CN111427610A (en) * 2020-03-25 2020-07-17 山东浪潮通软信息科技有限公司 Method, device, equipment and readable medium for integrating third-party services
CN112162873A (en) * 2020-09-28 2021-01-01 杭州安恒信息技术股份有限公司 Remote calling method, electronic device and storage medium
CN112597187A (en) * 2021-03-03 2021-04-02 北京冠新医卫软件科技有限公司 GraphQL query method and device based on FHIR standard
CN113225379A (en) * 2021-03-31 2021-08-06 北京三快在线科技有限公司 Method and device for sending HTTP request message
CN114064690A (en) * 2021-11-17 2022-02-18 中国工商银行股份有限公司 Data processing method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
MOB604756EF1373: "分分钟将REST转换为GraphQL", pages 1 - 10, Retrieved from the Internet <URL:https://blog.51cto.com/u_15127556/2714931> *

Similar Documents

Publication Publication Date Title
US11144711B2 (en) Webpage rendering method, device, electronic apparatus and storage medium
CN110019350B (en) Data query method and device based on configuration information
CN108696381B (en) Protocol configuration method and device
CN107872437B (en) Method, device and server for service request
CN106997298B (en) Application resource acquisition method and device
US8645490B2 (en) Web site implementation by mapping expression evaluation
CN109117252B (en) Method and system for task processing based on container and container cluster management system
CN109194714B (en) File pushing method and device, terminal device and storage medium
CN102567400B (en) Method for realizing Web visit and Web server
JP5677319B2 (en) Web-based diagram visual extensibility
RU2580079C2 (en) Application activation framework
CN111949856B (en) Web-based object storage query method and device
EP3279816A1 (en) Data analysis processing method, apparatus, computer device, and storage medium
WO2021203918A1 (en) Method for processing model parameters, and apparatus
CN112256772A (en) Data service method, device and readable storage medium
US10673953B2 (en) Transport channel via web socket for OData
CN110941655B (en) Data format conversion method and device
US12001458B2 (en) Multi-cloud object store access
CN114816403A (en) Request processing method, device, equipment and storage medium
Baraki et al. Sam: A semantic-aware middleware for mobile cloud computing
CN112596729B (en) Target application interface generation method and device, readable medium and electronic equipment
CN114817794A (en) Webpage content control method, device, equipment and medium
Zdravković et al. Model-based, client-side integration of heterogeneous data from REST services
US10133758B2 (en) Cell-based database management system
US11968204B2 (en) Generic middleware system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination