[go: up one dir, main page]

CN114816403B - A request processing method, device, equipment and storage medium - Google Patents

A request processing method, device, equipment and storage medium Download PDF

Info

Publication number
CN114816403B
CN114816403B CN202210411950.8A CN202210411950A CN114816403B CN 114816403 B CN114816403 B CN 114816403B CN 202210411950 A CN202210411950 A CN 202210411950A CN 114816403 B CN114816403 B CN 114816403B
Authority
CN
China
Prior art keywords
request
variable
api
target variable
analysis
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.)
Active
Application number
CN202210411950.8A
Other languages
Chinese (zh)
Other versions
CN114816403A (en
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/CN114816403B/en
Publication of CN114816403A publication Critical patent/CN114816403A/en
Application granted granted Critical
Publication of CN114816403B publication Critical patent/CN114816403B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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 OR CALCULATING; 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

本公开提供了一种请求处理方法、装置、设备及存储介质,所述方法包括:接收来自第一应用程序接口API的待解析请求,确定第一API对应的解析模板定义,基于第一目标变量的数据源,从待解析请求中获取第一目标变量对应的变量值,基于第一目标变量对应的变量值和变量类型,构建待解析请求对应的解析结果请求,并将解析结果请求发送至预设API。本公开通过将来自第一API的待解析请求解析成预设API可识别的解析结果请求,相比现有技术将前后端完整迁移到支持GraphQL的软件架构,本公开支持仅改造业务系统的部分架构(如后端),也可以不影响业务系统的功能,降低了由此产生的改造成本。

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.

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 method, an apparatus, a device, and a storage medium for processing a request.
Background
REST (Representational STATE TRANSFER) is a design style and development mode of a network application program, and a RESTful API (Application ProgrammingInterface, application program interface) obtained based on REST encapsulation makes front-end and back-end separation and data interaction very easy, so that the RESTful API becomes a popular software architecture design mode in the internet field.
However, since the data required by different service scenarios of the front end may be similar but have some differences, and 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 service scenarios, and the workload of the developer is increased. Thus, there is often a need for a retrofit for business systems developed based on RESTful APIs, and GraphQL currently provides a more efficient, powerful, and flexible alternative to REST.
In the related art, there is a software architecture for completely migrating the front end and the back end to support GraphQL (Graph Query Language, graphical data query language), and all interfaces use the modification scheme of GRAPHQL API, but the modification cost generated by the modification scheme is high.
Disclosure of Invention
In order to solve the above technical problems, an embodiment of the present disclosure provides a request processing method.
In a first aspect, the present disclosure provides a request processing method, the 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 pattern;
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;
based on the data source of the first target variable, acquiring a variable value corresponding to the first target variable from the request to be analyzed;
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; wherein the preset API is generated based on the second API design mode.
In an optional implementation manner, the analysis 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, where the second target variable is used to construct an analysis result request corresponding to the request to be analyzed;
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 comprises the following steps:
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 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 includes:
And constructing an analysis result request corresponding to the request to be analyzed based on the variable values and the variable types respectively corresponding to the first target variable and the second target variable.
In an optional implementation manner, the constructing, based on the variable value and the variable type corresponding to the first target variable, the parsing result request corresponding to the request to be parsed 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 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:
And carrying out grammar 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 parsed 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 URL in the HTTP request.
In an alternative 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 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, based on the data source of the first target variable, a variable value corresponding to the first target variable from the request to be analyzed, 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; wherein the preset API is generated based on the second API design mode;
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 the first application program interface API; wherein the first API is generated based on a first API design pattern;
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; wherein 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 instructions stored therein, which when run on a terminal device, cause the terminal device to implement the above-described method.
In a fifth aspect, the present disclosure provides an apparatus comprising: the computer program comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the processor realizes the method when executing the computer program.
In a sixth aspect, the present disclosure provides a computer program product comprising computer programs/instructions which when executed by a processor implement the above-described method.
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; wherein the preset API is generated based on the second API design pattern. 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, so that the front end and the rear end of the same service system can be realized based on different API design modes, and therefore, compared with the prior art, the front end and the rear end are completely migrated to the software architecture supporting GraphQL, the method and the device support the transformation of only part of the architecture (such as the rear end) of the service system, the function of the service system can not be influenced, and the transformation cost generated by the method and the device is reduced.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure.
In order to more clearly illustrate the embodiments of the present disclosure or the solutions in the prior art, the drawings that are required for the description of the embodiments or the prior art will be briefly described below, and it will be obvious to those skilled in the art that other drawings can be obtained from these drawings without inventive effort.
FIG. 1 is a schematic diagram of a request processing system according to an embodiment of the disclosure;
FIG. 2 is a schematic diagram of a request processing system implementation process according to an embodiment of the present disclosure;
FIG. 3 is a flowchart of a request processing method according to an embodiment of the present disclosure;
FIG. 4 is a flow chart of another request processing method provided by an embodiment of the present disclosure;
Fig. 5 is a schematic structural diagram of a request processing device 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, a further description of aspects of the present disclosure will be provided below. It should be noted that, without conflict, the embodiments of the present disclosure and features in the embodiments may be combined with each other.
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 otherwise than as described herein; it will be apparent that the embodiments in the specification are only some, but not all, embodiments of the disclosure.
REST is a design style and development mode of a network application program, and a REST packaging-based RESTful API enables front-end and back-end separation and data interaction to be very easy, so that the RESTful API becomes a popular software architecture design mode in the field of Internet.
However, since the data required by different service scenarios of the front end may be similar but have some differences, and 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 service scenarios, and the workload of the developer is increased. Thus, there is often a need for a retrofit for business systems developed based on RESTful APIs, and GraphQL currently provides a more efficient, powerful, and flexible alternative to REST.
In the related art, there is a software architecture for completely migrating the front end and the back end to support GraphQL (Graph Query Language, graphical data query language), and all interfaces use the modification scheme of GRAPHQL API, but the modification cost generated by the modification scheme is high.
For this reason, the present disclosure provides a request processing method, which receives a request to be parsed 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; wherein the preset API is generated based on the second API design pattern. 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, so that the front end and the rear end of the same service system can be realized based on different API design modes, and therefore, compared with the prior art, the front end and the rear end are completely migrated to the software architecture supporting GraphQL, the method and the device support the transformation of only part of the architecture (such as the rear end) of the service system, the function of the service system can not be influenced, and the transformation cost generated by the method and the device is reduced.
To facilitate understanding of the overall solution, the disclosure first introduces a request processing system, specifically, the request processing system (may also be referred to as the service system described above) includes a client, a server, and a request parsing engine, and referring to fig. 1, a schematic structural diagram of a request processing system is provided for an embodiment of the disclosure.
The request processing system 100 includes a client 101, a request analysis engine 102, and a server 103, where the client 101 is connected to the request analysis engine 102 through communication, and the request analysis engine 102 is connected to the server 103 through communication.
Specifically, the client 101 is configured to send, through a first application program interface API, a request to be parsed to a request parsing engine; the client generates the first API based on the first API design mode, and the first API generates the first API based on the first API design mode.
The client 101 may be a smart phone, a Personal digital assistant (Personal DIGITAL ASSISTANT, PDA), a Tablet (Tablet Personal Computer, tablet PC), a PMP (portable multimedia player), a vehicle-mounted terminal (e.g., a vehicle-mounted 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 a 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; wherein the preset API is generated based on the second API design pattern.
The server 103 is used for processing the analysis result request; 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 ease of understanding, the first API is taken as a first RESTful API, and the preset API is GRAPHQL API as an example.
In an embodiment of the disclosure, the client sends a request to be parsed, such as an HTTP (HyperText Transfer Protocol ) request to a request parsing engine, through a first RESTful API.
After receiving an HTTP request to be analyzed sent by a client, a request analysis engine determines an analysis template definition corresponding to a first RESTful API, analyzes the analysis template definition to obtain a data source and a variable type of a first target variable corresponding to the first RESTful API, obtains a variable value corresponding to the first target variable from the HTTP request to be analyzed based on the data source of the first target variable, constructs an analysis result request corresponding to the HTTP request to be analyzed based on the variable value and the variable type corresponding to the first target variable, and sends the analysis result request to a service end GRAPHQL API.
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 embodiments of the present disclosure, referring to fig. 2, a schematic process diagram of a request processing system provided by the embodiments of the present disclosure is implemented, as shown in fig. 2, a request to be resolved may be from a/API/book of a first RESTful API, or may be from a/API/author of a second RESTful API, or may be from a/API/user of a third RESTful API, taking a/API/book of the first RESTful API as an example, a client sends a/API/book of the first RESTful API to a request resolving engine, the request resolving engine first determines a data source and a variable type of a first target variable corresponding to the first RESTful API from the resolving template definition after receiving the/API/book of the first RESTful API, obtains a data source and a variable type of the first target variable corresponding to the first RESTful API from the resolving template definition, obtains a corresponding variable value from the request to be resolved, and sends a corresponding variable type to a request to be resolved based on the corresponding variable type of the first target variable and a result to be resolved request, and a result is constructed to be resolved to a request resolving request to be a service request.
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 GRAPHQL API identifiable analysis result request based on the request analysis engine, so that the capacity of using the first RESTful API by the client and using GRAPHQL API by the corresponding server is realized, the transformation cost problem caused by replacing the first RESTful API by the client is reduced, and the workload of a developer of the server is reduced.
Based on this, an embodiment of the present disclosure provides a request processing method, referring to fig. 3, which is a flowchart of the request processing method provided by the embodiment of the present disclosure, where the method includes:
S301: and receiving a request to be resolved from the first application program interface API.
Wherein the first API is generated based on a first API design schema, such as: the first API may be a first RESTful API designed based on RESTful architectural modes.
The RESTful architecture conforms to the constraint conditions and principles of REST and is used for realizing the performance state transformation of resources, specifically, each URI (UniformResource Identifier ) represents a resource, and the resource of the server is operated based on the HTTP request of the client to realize the performance state transformation, for example: when the client is a Delete request in the HTTP request, it means that the resource is deleted from the server.
The request to be analyzed refers to request information sent by the client, taking an HTTP request as an example, where the HTTP request includes Query information, request Header information, cookie information, body structure or preset interface information carried by URL (Uniform Resource Locator ), and the preset interface information refers to information contained in other requests and has an indirect corresponding relationship with the HTTP request.
Specifically, referring to fig. 4, a flowchart of another request processing method provided in an embodiment of the present disclosure is shown in fig. 4, taking an HTTP request to be parsed of the first RESTful API as an example, where/API/doublernum =50 is from Query information carried by URL, and a Header: "username=seven" from Header information Cookie: "token=abc123" from Cookie information, session: "appid=13" comes from preset interface information.
S302: and determining the definition of the parsing template corresponding to the first API.
The analysis template definition is determined based on the 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 a request to be analyzed.
Specifically, taking the second AIP as GRAPHQL API as an example, the parsing template is defined as determining based on GRAPHQL API design mode, GRAPHQL API design mode is GraphQL architecture mode, specifically GraphQL architecture is declarative data acquisition, and accurate data return is achieved through an interface, for example, when the client needs to request the user ID, the server accurately returns the user ID based on GRAPHQL API.
With continued reference to fig. 4, taking the first AIP as an example of the first RESTful API, after receiving the HTTP request to be parsed sent by the first RESTful API, the request parsing engine portal determines a parsing template definition corresponding to the first RESTful API, where the parsing template definition defines a data source and a variable type of a first target variable corresponding to the first RESTful API, taking the first target variable as an example of the Token variable, the parsing template defines a data source of Token as Header information, and the data type of Token is Int.
In an alternative embodiment, the parsing template definition may be stored as a structured file, such as a JSON file, and by performing syntax parsing on the parsing template definition corresponding to the first API, a data source of the first target variable corresponding to the first API and a variable type of the first target variable are obtained, and with continued reference to fig. 4, as follows, the JSON file of the parsing template definition corresponding to the first RESTful API is shown in the following manner:
{
"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 based on GraphQL schema.
S303: 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 analyzed.
The data source of the first target variable comprises Query information, request Header information, cookie information, body structure 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 indirect corresponding relation with the HTTP request.
In this embodiment of the present disclosure, after a data source of a first target variable corresponding to a first API is obtained in an parsing template definition, a variable value corresponding to the first target variable is obtained from a request to be parsed of the first API, and referring to fig. 4, taking the first target variable as a UserName variable as an example, after obtaining that the data source of the UserName variable is Header information, based on the Header information, a variable value seven of the UserName variable is obtained from the request to be parsed of the first API.
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, and specifically, the preset API may be set according to a service scenario, for example, may be GRAPHQL API, GRAPHQL API 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 into 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 GraphQL as an example, and the preset request template is a preset template for constructing the GraphQL requested template.
In the embodiment of the disclosure, with continued reference to fig. 4, after determining the variable value and the variable type corresponding to the first target variable, a preset request template is obtained, the variable value and the variable type corresponding to the first target variable are filled into the preset request template, an analysis result request corresponding to the request to be analyzed is generated, with reference to fig. 4, taking the first target variable as an app id variable as an example, after determining the variable value of the app id variable as 13 and the variable type as Int, the variable value and the variable type are input into the preset request template, the analysis result request is generated, and then the analysis request is sent to 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; wherein the preset API is generated based on the second API design pattern. The method and the device solve the problem of reconstruction cost caused by replacing the first RESTful API by the client and reduce the workload of a developer of the server simultaneously based on the capability of the client to use the first RESTful API and the corresponding service to use GRAPHQL API by analyzing the request to be analyzed from the first RESTful API to be the request of GRAPHQL API which is the identifiable analysis result request based on the request analysis engine.
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, the second target variable is used for constructing 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 corresponding to the first target variable and the second target variable respectively.
Continuing to refer to fig. 4, taking a second target variable as a num variable as an example, taking the num variable as an expression form, after receiving an HTTP request to be parsed of the first RESTful API, determining a data source of an intermediate variable included in the expression of the num variable based on a parsing template definition, acquiring a variable value corresponding to the intermediate variable, then calculating a variable value corresponding to the num variable, namely num=50%100=50, by a logic calculation module based on the variable value and the expression of the intermediate variable, and finally constructing a parsing result request corresponding to the HTTP request to be parsed of the first RESTful API based on the first target variable Token, userName and the AppID and the variable type corresponding to the second target variable num, respectively, as follows:
{
"token": "abc123",
"num": "50",
"userName": "seven",
"appID": "13"
}
it should be noted that, in order to meet the service scenario requirement, the logic calculation module may also support a for loop flow, which is not limited in this disclosure.
In the embodiment of the disclosure, when the second target variable is an expression, based on a data source of an intermediate variable contained in the expression, a variable value corresponding to the intermediate variable is obtained, based on the variable value corresponding to the intermediate variable and the expression, a logic calculation module is utilized to calculate the variable value corresponding to the second target variable, and then, based on the variable value corresponding to the second target variable and the variable type, an analysis result request corresponding to the request to be analyzed is constructed, so that when the second target variable contained in the request to be analyzed is the expression, the conversion between the request to be analyzed and the analysis result request is realized.
Based on the above method embodiments, the present disclosure further provides a request processing device, and referring to fig. 5, a schematic structural diagram of the request processing device provided in the embodiments of the present disclosure is provided, where the device includes:
A receiving module 501, 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;
A determining module 502, configured to determine an parsing 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, from the request to be parsed, a variable value corresponding to the first target variable based on a data source of the first target variable;
A construction module 504, configured to 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; wherein the preset API is generated based on the second API design mode.
In an optional implementation manner, the analysis 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, where the second target variable is used to construct an analysis result request corresponding to the request to be analyzed;
before the building module is based, the method further comprises:
the first acquisition submodule is used for 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;
The calculating sub-module is used for calculating the variable value corresponding to the second target variable based on the variable value corresponding to the intermediate variable and the expression;
correspondingly, the construction module is specifically configured to:
And constructing an analysis result request corresponding to the request to be analyzed based on the variable values and the variable types respectively corresponding to the first target variable and the second target variable.
In an alternative embodiment, the building block comprises:
the second acquisition sub-module is used for acquiring a preset request template; the preset request template is set based on the second API design mode;
The generation sub-module is used for 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 the request to be analyzed.
In an alternative embodiment, the parsing template definition is stored as a structured file, and before the obtaining module, the method further includes:
The analysis module is used for carrying out grammar 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 parsed 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 URL in the HTTP request.
In an alternative 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; wherein the preset API is generated based on the second API design pattern. 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, so that the front end and the rear end of the same service system can be realized based on different API design modes, and therefore, compared with the prior art, the front end and the rear end are completely migrated to the software architecture supporting GraphQL, the method and the device support the transformation of only part of the architecture (such as the rear end) of the service system, the function of the service system can not be influenced, and the transformation cost generated by the method and the device is reduced.
In addition to the above methods and apparatuses, the embodiments of the present disclosure further provide a computer readable storage medium, where instructions are stored, when the instructions are executed on a terminal device, cause the terminal device to implement the request processing method according to the embodiments of the present disclosure.
The disclosed embodiments also provide a computer program product comprising a computer program/instruction which, when executed by a processor, implements the request processing method described in the disclosed embodiments.
In addition, the embodiment of the disclosure further provides a request processing device, which, as shown in fig. 6, 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, one processor being exemplified in fig. 6. In some embodiments of the present disclosure, the processor 601, memory 602, input device 603, and output device 604 may be connected by a bus or other means, with the bus connection being 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 executing the software programs and modules stored in the memory 602. The memory 602 may primarily include a storage program area and a storage data area, wherein the storage program area may store an operating system, application programs required for at least one function, and the like. In addition, 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 means 603 may be used to receive input numeric or character information and to generate signal inputs related to user settings and function control of the requesting processing device.
In particular, in this embodiment, the processor 601 loads executable files corresponding to the processes of one or more application programs into the memory 602 according to the following instructions, and the processor 601 executes the application programs stored in the memory 602, thereby implementing the various functions of the request processing device.
It should be noted that in this document, relational terms such as "first" and "second" and the like are 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. Moreover, 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 one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The foregoing is merely a specific embodiment of the disclosure to enable one skilled in the art to understand or practice the 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 and described herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (11)

1. A method of request processing, the method comprising:
Receiving a request to be parsed from a first API; wherein the first API is generated based on a first API design pattern;
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, the first target variable is used for constructing an analysis result request corresponding to the request to be analyzed, and the data source of the first target variable and the variable type of the first target variable are obtained by analysis from the analysis template definition;
based on the data source of the first target variable, acquiring a variable value corresponding to the first target variable from the request to be analyzed;
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; wherein the preset API is generated based on the second API design mode.
2. The method of claim 1, wherein 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, 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 comprises the following steps:
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 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 includes:
And constructing an analysis result request corresponding to the request to be analyzed based on the variable values and the variable types respectively corresponding to the first target variable and the second target variable.
3. The method according to claim 1, wherein the constructing the parsing result request corresponding to the request to be parsed based on the variable type and the value 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.
4. The method according to claim 1, wherein the parsing template definition is stored as a structured file, and before the obtaining, from the request to be parsed, the variable value corresponding to the first target variable based on the data source of the first target variable, the method further comprises:
And carrying out grammar 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 of claim 1, wherein the request to be parsed 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 URL in the HTTP request.
6. The method of claim 1, wherein the first API design mode is a RESTful architecture mode and the second API design mode is a GraphQL architecture mode.
7. The 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 API; wherein the first API is generated based on the first API design pattern;
The request analysis engine 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, based on the data source of the first target variable, a variable value corresponding to the first target variable from the request to be analyzed, 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; wherein the preset API is generated based on the second API design mode, and the analysis template is defined as being determined based on the second API design mode;
the server is used for processing the analysis result request.
8. A request processing apparatus, the apparatus comprising:
the receiving module is used for receiving a request to be analyzed from the first API; wherein the first API is generated based on a first API design pattern;
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, the first target variable is used for constructing an analysis result request corresponding to the request to be analyzed, and the data source of the first target variable and the variable type of the first target variable are obtained by analysis from the analysis template definition;
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; wherein the preset API is generated based on the second API design mode.
9. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein instructions, which when run on a terminal device, cause the terminal device to implement the method according to any of claims 1-6.
10. A request processing apparatus, characterized by comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the method of any one of claims 1-6 when the computer program is executed.
11. A computer program product, characterized in that it comprises a computer program/instruction which, when executed by a processor, implements the method according to any of claims 1-6.
CN202210411950.8A 2022-04-19 2022-04-19 A request processing method, device, equipment and storage medium Active CN114816403B (en)

Priority Applications (1)

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

Applications Claiming Priority (1)

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

Publications (2)

Publication Number Publication Date
CN114816403A CN114816403A (en) 2022-07-29
CN114816403B true CN114816403B (en) 2024-11-12

Family

ID=82505854

Family Applications (1)

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

Country Status (1)

Country Link
CN (1) CN114816403B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111865881A (en) * 2019-04-30 2020-10-30 北京数聚鑫云信息技术有限公司 Interface conversion method, device, medium and computer equipment

Family Cites Families (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7490295B2 (en) * 2004-06-25 2009-02-10 Apple Inc. Layer for accessing user interface elements
WO2019079551A1 (en) * 2017-10-20 2019-04-25 Heretik Inc. Method and system for dynamically configuring a user interface for a specified document review task
CN107948135B (en) * 2017-10-31 2020-02-21 贵州白山云科技股份有限公司 Data processing method and device supporting multiple API protocols
US10776189B2 (en) * 2017-12-22 2020-09-15 MuleSoft, Inc. API query
US10725840B2 (en) * 2018-11-13 2020-07-28 American Express Travel Related Services Company, Inc. Automated web service and API build configuration framework
US10747505B1 (en) * 2019-05-17 2020-08-18 Google Llc API specification generation
CN110738024A (en) * 2019-09-24 2020-01-31 深圳丝路天地电子商务有限公司 Method for converting WebAPP into API service interface
CN110738036A (en) * 2019-10-15 2020-01-31 北京百度网讯科技有限公司 Method and apparatus for generating information
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
CN112162873B (en) * 2020-09-28 2024-03-26 杭州安恒信息技术股份有限公司 Remote calling method, electronic device and storage medium
CN112597187B (en) * 2021-03-03 2021-06-29 北京冠新医卫软件科技有限公司 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
CN113703862B (en) * 2021-07-12 2024-08-06 新华三大数据技术有限公司 Configuration-based interface calling method, device, equipment and storage medium
CN114064690A (en) * 2021-11-17 2022-02-18 中国工商银行股份有限公司 Data processing method and device

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111865881A (en) * 2019-04-30 2020-10-30 北京数聚鑫云信息技术有限公司 Interface conversion method, device, medium and computer equipment

Also Published As

Publication number Publication date
CN114816403A (en) 2022-07-29

Similar Documents

Publication Publication Date Title
CN102346770B (en) WebKit browser webpage content loading method and device
CN110019350B (en) Data query method and device based on configuration information
CN113536748B (en) A method and device for generating chart data
US11689626B2 (en) Transport channel via web socket for ODATA
CN112256772A (en) Data service method, device and readable storage medium
JP5677319B2 (en) Web-based diagram visual extensibility
US20160072927A1 (en) Odata enabled mobile software applications
CN104391868A (en) Staticizing device and method for dynamic page
CN110020329A (en) For generating the methods, devices and systems of webpage
CN111753226A (en) A page loading method and device
CN112948737A (en) HTML page screenshot method and system
JP5039946B2 (en) Technology for relaying communication between client devices and server devices
CN113448995A (en) Database operation method, device and system, electronic equipment and storage medium
CN113312188B (en) Data processing method, data interaction system and computing device
CN114816403B (en) A request processing method, device, equipment and storage medium
CN114510501A (en) Method and device for processing interface data in real time
CN116561013B (en) Test methods, devices, electronic equipment and media based on the target service framework
CN114090015B (en) A page DSL parsing method, system, device and storage medium
CN107368478A (en) A method and device for processing web application requests on a server
Baraki et al. Sam: A semantic-aware middleware for mobile cloud computing
US11301498B2 (en) Multi-cloud object store access
CN114817794A (en) Webpage content control method, device, equipment and medium
CN117194463A (en) A method and device for querying report data
US10878187B1 (en) Network-based content rendering
US11095748B1 (en) Network-based content rendering

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
GR01 Patent grant
GR01 Patent grant