Application gateway implementation method and device based on transaction code, equipment and storage medium

By receiving and processing user transaction requests in the application gateway, and using authentication flag bits and transaction code information to forward directly to the target microservice, the problem of reloading configuration files for each microservice routing rule adjustment in the prior art is solved, and the configuration files are not required to be changed frequently, reducing operation and maintenance costs.

CN120583153APending Publication Date: 2025-09-02AGRICULTURAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510715246.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-30
Publication Date
2025-09-02

AI Technical Summary

Technical Problem

In the prior art, each adjustment of microservice routing rules requires reloading the configuration file, resulting in high operation and maintenance costs.

Method used

By receiving transaction requests from the user client, preprocessing and obtaining authentication flag bits, authenticating based on authentication flag bits, building a transaction request body and parsing the interface request address, and forwarding it directly to the target microservice to avoid frequent changes to the configuration file.

Benefits of technology

When microservices are added or new transactions, there is no need to change configuration files frequently, which reduces the workload of staff and reduces operation and maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120583153A_ABST
    Figure CN120583153A_ABST
Patent Text Reader

Abstract

The invention discloses an application gateway implementation method and device based on a transaction code, equipment and a storage medium. The method is characterized by comprising the following steps: receiving a first transaction request sent by a user client, preprocessing transaction request information, and determining a second transaction request; acquiring an authentication flag bit from the second transaction request, and authenticating the second transaction request based on the authentication flag bit to obtain an authentication result message; under the condition that the second transaction request is successfully authenticated, determining a third transaction request based on the authentication result message and the second transaction request; constructing a transaction request body for the request type of the third transaction request, and analyzing the third transaction request to obtain an interface request address and a transaction request header; and forwarding the transaction request header and the transaction request body to the target micro-service. According to the invention, through decoupling with the authentication service, the flexibility of implementation and deployment of the authentication service is increased; and in addition, when the micro-service is added or newly transacted, configuration files do not need to be frequently changed, and the workload of workers is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of microservice technology, and in particular to a transaction code-based application gateway implementation method, apparatus, device, and storage medium. Background Art

[0002] The microservices architecture is a cloud-native architectural approach that encompasses numerous loosely coupled, independently deployable small components or services within a single application. A microservice is a collection of smaller, loosely coupled services that form an application. When a client accesses a microservice, it must pass through an application gateway between the microservice and the client. The application gateway is typically a server that serves as the client's sole entry point to the microservice. The application gateway offers features such as authentication monitoring, load balancing, caching, protocol conversion, current limiting, and static response processing. When a client needs to access a microservice, the client's request is sent through the application gateway, which then forwards the request to the microservice. In existing technologies, the application gateway's microservice forwarding rules must be configured in a configuration file. Each adjustment to the microservice routing rules requires reloading the configuration file, resulting in high operational and maintenance costs. Summary of the Invention

[0003] The present invention provides a transaction code-based application gateway implementation method, apparatus, device and storage medium to solve the technical problem in the prior art that a configuration file needs to be reloaded each time a microservice routing rule is adjusted.

[0004] According to one aspect of the present invention, a method for implementing an application gateway based on a transaction code is provided, comprising:

[0005] receiving a first transaction request sent by a user client, pre-processing the first transaction request, and determining a second transaction request;

[0006] obtaining an authentication flag in the second transaction request, authenticating the second transaction request based on the authentication flag, and obtaining the authentication result message;

[0007] If the authentication of the second transaction request is successful, determining a third transaction request based on the authentication result message and the second transaction request;

[0008] Constructing a transaction request body for the third transaction request, and parsing the third transaction request to obtain an interface request address and a transaction request header;

[0009] The transaction request header and the transaction request body are forwarded to the target microservice based on the interface request address.

[0010] According to another aspect of the present invention, there is provided a device for implementing an application gateway based on a transaction code, comprising:

[0011] a request preprocessing module, configured to receive a first transaction request sent by a user client, preprocess the first transaction request, and determine a second transaction request;

[0012] an authentication module, configured to obtain an authentication flag in the second transaction request, authenticate the second transaction request based on the authentication flag, and obtain the authentication result message;

[0013] a request conversion module, configured to determine a third transaction request based on the authentication result message and the second transaction request if the second transaction request is successfully authenticated;

[0014] a request body construction module, configured to construct a transaction request body for the third transaction request, and parse the third transaction request to obtain an interface request address and a transaction request header;

[0015] A forwarding module is used to forward the transaction request header and the transaction request body to a target microservice based on the interface request address.

[0016] According to another aspect of the present invention, an electronic device is provided, comprising:

[0017] at least one processor; and

[0018] a memory communicatively connected to the at least one processor; wherein,

[0019] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the transaction code-based application gateway implementation method described in any embodiment of the present invention.

[0020] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the transaction code-based application gateway implementation method described in any embodiment of the present invention when executed.

[0021] The technical solution of an embodiment of the present invention is to receive a first transaction request sent by a user client, pre-process the first transaction request, and determine a second transaction request; obtain an authentication flag in the second transaction request, authenticate the second transaction request based on the authentication flag, and obtain the authentication result message; if the second transaction request is successfully authenticated, determine a third transaction request based on the authentication result message and the second transaction request; construct a transaction request body for the third transaction request, and parse the third transaction request to obtain an interface request address and a transaction request header; and forward the transaction request header and the transaction request body to the target microservice based on the interface request address. This solves the technical problem in the prior art of requiring the configuration file to be reloaded each time the microservice routing rules are adjusted; and can achieve the goal of eliminating the need to frequently change the configuration file when adding microservices or new transactions, thereby reducing staff workload and effectively lowering operation and maintenance costs.

[0022] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0024] Figure 1 A flowchart of a method for implementing an application gateway based on a transaction code is provided for an embodiment of the present invention;

[0025] Figure 2 A flowchart of a transaction code-based application gateway implementation method provided by an embodiment of the present invention;

[0026] Figure 3 A structural diagram of an application gateway deployed in a transaction code-based application gateway implementation method disclosed in an embodiment of the present invention;

[0027] Figure 4 A schematic diagram of the structure of a transaction code-based application gateway implementation device provided by an embodiment of the present invention;

[0028] Figure 5 FIG. 1 is a schematic structural diagram of an electronic device 10 that can be used to implement an embodiment of the present invention. DETAILED DESCRIPTION

[0029] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.

[0030] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0031] Figure 1 The present invention provides a flowchart of a transaction code-based application gateway implementation method. This embodiment is applicable to the case where a filter is set in the application gateway and the user client's request to access the microservice is forwarded through the filter. The method can be executed by a transaction code-based application gateway implementation device. The transaction code-based application gateway implementation device can be implemented in the form of hardware and / or software. The transaction code-based application gateway implementation device can be configured in an electronic device. Figure 1 As shown, the method includes:

[0032] S110: Receive a first transaction request sent by a user client, pre-process the first transaction request, and determine a second transaction request.

[0033] The user client can send a first transaction request to the application gateway requesting a microservice. The first transaction request can be an HTTP request, and the transaction request header of the first transaction request should include at least a request transaction code and a request content type. The request transaction code can consist of a module name, an HTTP request type, and a sequence number. The module name can be the name of the module that implements the application functionality on the user client. The HTTP request type can be the HTTP method in the transaction request header. The sequence number can be a five-digit numerical number set in the transaction request header, starting at 1 and padded with zeros to a maximum of five digits. The transaction request header structure can be module name_HTTP request type_sequence number. For example, the module names can be auth and tsbox, the HTTP request types can be GET and POST, the sequence numbers can be 00001 and 00021, and the transaction request headers can be auth_GET_0001 and tsbox_POST_00021, respectively, for authenticating the user client.

[0034] The second transaction request may be a request obtained by preprocessing the first transaction request. It should be noted that the second transaction request is obtained by preprocessing the first transaction request and adding an authentication flag to the first transaction request.

[0035] Specifically, a first transaction request sent by a user client is received, the first transaction request is pre-processed, and a second transaction request is determined.

[0036] S120: Obtain an authentication flag in the second transaction request, authenticate the second transaction request based on the authentication flag, and obtain the authentication result message.

[0037] The authentication flag can be used to authenticate and determine the permissions of the requesting user client. It should be noted that the authentication flag can be used to identify the user client's identity and permissions to determine whether the user client's identity and permissions are sufficient to invoke the microservice through the second transaction request. For example, if a request is to invoke the backend management service of a microservice, it is necessary to verify whether the user client's identity is that of an administrator and whether the administrator has the permissions to access the backend management service.

[0038] Optionally, in the present invention, the authentication function can be any functional service with identity authentication and authority authentication. The authentication function is not integrated in the application gateway. The authentication function cabinet can be deployed in the microservice connected to the application gateway, or it can be deployed outside the microservice and decoupled from the application gateway. The application gateway and the authentication function communicate through messages, send the second transaction request to the authentication function, and receive the authentication result message returned by the authentication function. Among them, the authentication result message can be the message returned after the authentication function performs an authentication judgment on the second transaction request. It should be noted that the authentication result message includes the HTTP response code of the authentication function, the authentication result information, the authentication result data field, the authentication result, and the unique ID of the user of the requesting client. Exemplarily, the authentication result message can be:

[0039]

[0040] Where code is the HTTP response code of the authentication function; message is the authentication result information, which is OK; data is the authentication result data field; data.result is the authentication result, where data.true indicates success and false indicates failure; and userid is the unique ID of the user requesting the client.

[0041] Specifically, an authentication flag is obtained in the second transaction request, the second transaction request is sent to the authentication function through a message, and the authentication function authenticates the second transaction request based on the authentication flag to obtain an authentication result message.

[0042] S130: If the second transaction request is successfully authenticated, determine a third transaction request based on the authentication result message and the second transaction request.

[0043] The authentication success may be that the authentication result in the authentication result message is displayed as authentication success.

[0044] The third transaction request may be a request obtained by modifying the second transaction request.

[0045] Specifically, the authentication result of the second transaction request in the authentication result message is obtained, and if the authentication of the second transaction request is successful, the third transaction request is determined based on the authentication result message and the second transaction request.

[0046] S140: Construct a transaction request body for the third transaction request, and parse the third transaction request to obtain an interface request address and a transaction request header.

[0047] The transaction request body may be a request content that carries the transaction data in the third transaction request; the transaction request body may be used to submit the request data to the microservice to obtain the reply content of the microservice.

[0048] Among them, the interface request address can be the microservice backend service address that the microservice receives as data; the application gateway sends the user client's request to the microservice based on the interface request address.

[0049] The transaction request header may be attribute data describing the request in an HTTP request. In an embodiment of the present invention, the transaction request header includes a request transaction code.

[0050] Specifically, a transaction request body is constructed for the third transaction request, and the third transaction request is parsed to obtain an interface request address and a transaction request header.

[0051] S150: Forward the transaction request header and the transaction request body to the target microservice based on the interface request address.

[0052] Specifically, the transaction request header and transaction request body are forwarded to the target microservice based on the interface request address, and the transaction request header and transaction request body are submitted to the target microservice, so that the target microservice responds to the request based on the transaction request header and transaction request body.

[0053] Optionally, in another optional embodiment of the present invention, after forwarding the transaction request header and the transaction request body to the target microservice based on the interface request address, it also includes: receiving a result message returned by the target microservice based on the transaction request header and the transaction request body; generating a client reply message based on the result message, and sending the client reply message to the client.

[0054] The result message may be the result information returned by the target microservice in response to the client request.

[0055] The client reply message may be message information generated when the application gateway replies to the application client with a result message.

[0056] Specifically, by receiving the result message returned by the target microservice based on the transaction request header and the transaction request body, modifying the response of the application gateway, generating a client reply message, and sending the client reply message to the application client.

[0057] Optionally, in another optional embodiment of the present invention, if the third transaction request complies with a preset transaction request method, an audit log of the third transaction request is recorded.

[0058] The preset transaction request method may be at least one preset HTTP request type; for example, the preset transaction request method may be PUT, POST, or DELETE.

[0059] Among them, the audit log can be the log information recorded by the application gateway in the application gateway of all information of the transaction request sent by the application client; it should be noted that the HTTP request type of the third transaction request is the same as that of the first transaction request, and the third transaction request complies with the preset transaction request method. The application gateway records the second transaction request, the third transaction request, the interface request address, the transaction request header, the transaction request body, the result message, the client reply message and the authentication result message corresponding to the first transaction request to generate an audit log.

[0060] Specifically, if the third transaction request conforms to the preset transaction request method, the audit log of the third transaction request is recorded; if the third transaction request does not conform to the preset transaction request method, the audit log is not recorded.

[0061] The technical solution of an embodiment of the present invention is to receive a first transaction request sent by a user client, pre-process the first transaction request, and determine a second transaction request; obtain an authentication flag in the second transaction request, authenticate the second transaction request based on the authentication flag, and obtain the authentication result message; if the second transaction request is successfully authenticated, determine a third transaction request based on the authentication result message and the second transaction request; construct a transaction request body for the third transaction request, and parse the third transaction request to obtain an interface request address and a transaction request header; and forward the transaction request header and the transaction request body to the target microservice based on the interface request address. This solves the technical problem in the prior art of requiring the configuration file to be reloaded each time the microservice routing rules are adjusted; and can achieve the goal of eliminating the need to frequently change the configuration file when adding microservices or new transactions, thereby reducing staff workload and effectively lowering operation and maintenance costs.

[0062] Figure 2 This is a flowchart of a transaction code-based application gateway implementation method provided by an embodiment of the present invention. The relationship between this embodiment and the above embodiment is to specifically introduce the specific process of pre-processing the first transaction request and processing the second transaction request. Figure 2 As shown, the method includes:

[0063] S210: Receive a first transaction request sent by a user client. If the first transaction request contains a requested transaction code, query a preset transaction code information table for complete transaction information corresponding to the requested transaction code.

[0064] The preset transaction code information table may be a pre-set data table for recording transaction code information. It should be noted that the preset transaction code information table includes a transaction code, transaction request type, transaction Chinese name, microservice name, authentication flag, and creation time. The transaction code stores the unique code number information within the system for the transaction request, the transaction request type field stores the HTTP request type, the transaction Chinese name stores the functional description of the transaction request, the authentication flag stores whether the transaction request requires authentication verification; if the authentication flag is 1, authentication verification is required; if the authentication flag is 0, authentication verification is not required; the microservice name may be used to store information about the microservice to which the transaction request belongs; the creation time may indicate the creation time of the transaction request in the transaction code information table; and the transaction code may be a unique key for the transaction code information table.

[0065] Optionally, the preset transaction code information table may be stored in a database of the application gateway or in a database outside the application gateway. By associating with the application gateway, the application gateway may access the transaction code information table in the database.

[0066] Optionally, after receiving the first transaction request sent by the user client, it is identified whether the transaction request header of the first transaction request contains a requested transaction code. If the requested transaction code does not exist, an error message "There is no transaction code information in the HTTP transaction request header" is generated.

[0067] Optionally, if it is identified that the transaction request header of the first transaction request contains a request transaction code, the database is connected to query the transaction complete information corresponding to the request transaction code in a preset transaction code information table to obtain the transaction complete information.

[0068] Optionally, if the complete transaction information corresponding to the requested transaction code cannot be found in the preset transaction code information table of the database, it means that the data record does not exist in the transaction code information table, and an error message "transaction request does not exist" is generated.

[0069] Specifically, a first transaction request sent by a user client is received. If the first transaction request contains a requested transaction code, complete transaction information corresponding to the requested transaction code is searched in a preset transaction code information table.

[0070] S220: Write the authentication flag in the complete transaction information into the first transaction request, and obtain the transaction request type of the first transaction request.

[0071] Optionally, after querying the complete transaction information of the first transaction request, the authentication flag in the transaction completion information is obtained, the authentication flag is written into the first transaction request, and the transaction request type of the first transaction request is obtained.

[0072] S230: If the transaction request type of the first transaction request is the same as the transaction request type of the complete transaction information, query the preset microservice backend service address table for the microservice backend service address corresponding to the first transaction request.

[0073] The preset microservice backend service address table may be a data table pre-set for recording microservice information. It should be noted that the preset microservice backend service address table includes the microservice name, microservice Chinese name, microservice backend service address, and creation time. The microservice name stores the English abbreviation of the microservice, the microservice Chinese name stores the Chinese name of the microservice, the microservice backend service address stores the access address provided by the microservice to the application gateway, and the creation time is the time when the data is recorded in the microservice backend service address table. The microservice name is the unique key of the microservice backend service address table.

[0074] Optionally, the microservice backend service address table and at least one transaction code information table are associated via microservice names. For example, if the microservice backend service address table contains a microservice named "order-service," then the microservice routing address table contains only one data record whose microservice name value is "order-service." In the transaction code information table, there are 1 to N data records whose microservice name value is "order-service," indicating that these 1 to N transactions all belong to the microservice "order-service."

[0075] Optionally, after obtaining the complete transaction information of the first transaction request, if the transaction request type of the first transaction request is the same as the transaction request type of the complete transaction information, indicating that the transaction request type of the first transaction request matches the complete transaction information, then based on the microservice name in the complete transaction information, the preset microservice backend service address table is queried, and the microservice backend service address is queried based on the microservice name in the preset microservice backend service address table to obtain the microservice backend service address corresponding to the first transaction request.

[0076] Optionally, if the transaction request type of the first transaction request is different from the transaction request type of the complete transaction information, indicating that the transaction request type of the first transaction request does not match the complete transaction information, an error message "transaction request type does not match interface information" is returned.

[0077] Optionally, when querying the preset microservice backend service address table based on the microservice name in the complete transaction information, if the data record corresponding to the microservice name cannot be found in the microservice backend service address table, an error message "The transaction request has no corresponding microservice information" is replied.

[0078] S240: Modify the first transaction request based on the microservice backend service address to determine the second transaction request.

[0079] Specifically, after querying the microservice backend service address, obtain the request path pointing to the target microservice in the first transaction request, concatenate the request path and the microservice backend service address to obtain the real interface request address, that is, the interface request address, write the interface request address into the first transaction request to obtain the second transaction request.

[0080] S250: Obtain an authentication flag in the second transaction request, authenticate the second transaction request based on the authentication flag, and obtain the authentication result message.

[0081] Optionally, in another optional embodiment of the present invention, authenticating the second transaction request based on the authentication flag to obtain the authentication result message includes:

[0082] If the authentication flag of the second transaction request is a preset authentication value, a preset authentication function is called to authenticate the second transaction request, and an authentication result message returned by the authentication function is obtained.

[0083] The preset authentication value may be a value pre-set for determining an authentication flag, and the preset authentication value may be set to 1.

[0084] The preset authentication function may be a function pre-set to authenticate transaction requests.

[0085] Specifically, if the authentication flag of the second transaction request is a preset authentication value, a preset authentication function is called to authenticate the second transaction request, and an authentication result message is obtained from the authentication function.

[0086] S260: If the authentication of the second transaction request is successful, determine a third transaction request based on the authentication result message and the second transaction request.

[0087] Optionally, in another optional embodiment of the present invention, when the second transaction request is successfully authenticated, determining the third transaction request based on the authentication result message and the second transaction request includes:

[0088] When the authentication result information in the authentication result message indicates that the authentication is successful, obtaining the user identifier in the authentication result message;

[0089] Write the user ID into the second transaction request, determine the

[0090] The user identifier may be a unique ID of the user requesting the client.

[0091] Specifically, when receiving the authentication result message replied by the authentication function and identifying that the authentication result information is successful, the user identifier in the authentication result data field is obtained and the user identifier is written into the second transaction request to obtain the second transaction request.

[0092] S270: Construct a transaction request body for the third transaction request, and parse the third transaction request to obtain an interface request address and a transaction request header.

[0093] S280: Forward the transaction request header and the transaction request body to the target microservice based on the interface request address.

[0094] The technical solution of an embodiment of the present invention is to receive a first transaction request sent by a user client, pre-process the first transaction request, and determine a second transaction request; obtain an authentication flag in the second transaction request, authenticate the second transaction request based on the authentication flag, and obtain the authentication result message; if the second transaction request is successfully authenticated, determine a third transaction request based on the authentication result message and the second transaction request; construct a transaction request body for the third transaction request, and parse the third transaction request to obtain an interface request address and a transaction request header; and forward the transaction request header and the transaction request body to the target microservice based on the interface request address. This solves the technical problem in the prior art of requiring the configuration file to be reloaded each time the microservice routing rules are adjusted; and can achieve the goal of eliminating the need to frequently change the configuration file when adding microservices or new transactions, thereby reducing staff workload and effectively lowering operation and maintenance costs.

[0095] Figure 3 This is a structural diagram of an application gateway deployed by a transaction code-based application gateway implementation method disclosed in an embodiment of the present invention. Figure 3 As shown, the application client sends a first transaction request to the application gateway, which is processed by the request pre-processing filter, transaction authentication filter, and request forwarding filter of the application gateway and forwarded to each target microservice. The audit log of the transaction request is recorded by the audit record filter;

[0096] A request pre-processing filter is used to obtain the request transaction code from the transaction request header of the first transaction request. If the transaction request header does not carry the request transaction code, an error message "no transaction code information in the HTTP transaction request header" is generated and returned to the application client;

[0097] If the transaction request header carries a request transaction code, the complete transaction information corresponding to the request transaction code is searched in the preset transaction code information table, and the authentication flag in the complete transaction information is written into the first transaction request for use by subsequent filters. If the complete transaction information corresponding to the request transaction code cannot be found in the preset transaction code information table in the database, an error message "transaction request does not exist" is generated and returned to the application client.

[0098] Obtain the transaction request type of the first transaction request in the first transaction request. If the transaction request type of the first transaction request is compared with the transaction request type of the complete transaction information, if the comparison is consistent, then in the preset microservice backend service address table, the microservice backend service address corresponding to the first transaction request is spliced ​​with the request path and the microservice backend service address to obtain the real interface request address, and the spliced ​​address is written into the first transaction request to obtain the second transaction request.

[0099] If the transaction request type of the first transaction request is different from the transaction request type of the complete transaction information, indicating that the transaction request type of the first transaction request does not match the complete transaction information, an error message "Transaction request type does not match interface information" is returned to the application client;

[0100] When querying the preset microservice backend service address table based on the microservice name in the complete transaction information, if the data record corresponding to the microservice name cannot be found in the microservice backend service address table, an error message "The transaction request has no corresponding microservice information" will be replied to the application client;

[0101] The transaction authentication filter is used to obtain the authentication flag in the second transaction request. When the authentication flag is 0, the transaction authentication filter is skipped. If the authentication flag is 1, the authentication function corresponding to the authentication transaction is called. The authentication transaction can be deployed within the microservice or outside the microservice and is decoupled from the gateway. The gateway only judges the authentication result based on the authentication result message returned by the parsed authentication function;

[0102] When receiving the authentication result message replied by the authentication function and identifying that the authentication result information is successful, the user identifier in the authentication result data field is obtained, and the user identifier is written into the second transaction request to obtain the second transaction request.

[0103] The request forwarding filter is used to construct a transaction request body for the third transaction request based on the request content type of the third transaction request based on the request body construction method, obtain the real interface request address in the third transaction request, forward the transaction request header and transaction request body to the target microservice, and receive the result message returned by the target microservice, modify the response of the request forwarding filter, and write the result message into the response of the filter, that is, the client reply message.

[0104] The audit record filter is used to record the audit log when the transaction request type of the third transaction request is a PUT, POST, or DELETE request, and record the request transaction code, request message (i.e., transaction request header and transaction request body), user ID, and transaction result (result message) information of this request in the audit log.

[0105] Figure 4 A schematic diagram of a transaction code-based application gateway implementation device provided by an embodiment of the present invention. Figure 4 As shown, the device includes: a request pre-processing module 410, an authentication module 420, a request conversion module 430, a request body construction module 440 and a forwarding module 450; wherein,

[0106] The request pre-processing module 410 is configured to receive a first transaction request sent by a user client, pre-process the first transaction request, and determine a second transaction request;

[0107] an authentication module 420 configured to obtain an authentication flag in the second transaction request, authenticate the second transaction request based on the authentication flag, and obtain the authentication result message;

[0108] a request conversion module 430 configured to, if the authentication of the second transaction request succeeds, determine a third transaction request based on the authentication result message and the second transaction request;

[0109] A request body construction module 440 is configured to construct a transaction request body for the third transaction request and parse the third transaction request to obtain an interface request address and a transaction request header;

[0110] The forwarding module 450 is configured to forward the transaction request header and the transaction request body to a target microservice based on the interface request address.

[0111] The technical solution of an embodiment of the present invention is to receive a first transaction request sent by a user client, pre-process the first transaction request, and determine a second transaction request; obtain an authentication flag in the second transaction request, authenticate the second transaction request based on the authentication flag, and obtain the authentication result message; if the second transaction request is successfully authenticated, determine a third transaction request based on the authentication result message and the second transaction request; construct a transaction request body for the third transaction request, and parse the third transaction request to obtain an interface request address and a transaction request header; and forward the transaction request header and the transaction request body to the target microservice based on the interface request address. This solves the technical problem in the prior art of requiring the configuration file to be reloaded each time the microservice routing rules are adjusted; and can achieve the goal of eliminating the need to frequently change the configuration file when adding microservices or new transactions, thereby reducing staff workload and effectively lowering operation and maintenance costs.

[0112] Optionally, the device further includes a result response module and a result reply module, wherein:

[0113] The result response module is used to receive the result message returned by the target microservice based on the transaction request header and the transaction request body;

[0114] The result reply module is used to generate a client reply message based on the result message, and send the client reply message to the application client.

[0115] Optionally, the request pre-processing module 410 is specifically configured to:

[0116] If the first transaction request has a requested transaction code, querying the preset transaction code information table for complete transaction information corresponding to the requested transaction code;

[0117] Writing the authentication flag in the complete transaction information into the first transaction request, and obtaining the transaction request type of the first transaction request;

[0118] If the transaction request type of the first transaction request is the same as the transaction request type of the complete transaction information, querying the microservice backend service address corresponding to the first transaction request in the preset microservice backend service address table;

[0119] The first transaction request is modified based on the microservice backend service address to determine the second transaction request.

[0120] Optionally, the authentication module 420 is specifically configured to:

[0121] If the authentication flag of the second transaction request is a preset authentication value, a preset authentication function is called to authenticate the second transaction request, and an authentication result message returned by the authentication function is obtained.

[0122] Optionally, the request conversion module 430 is specifically configured to:

[0123] When the authentication result information in the authentication result message indicates that the authentication is successful, obtaining the user identifier in the authentication result message;

[0124] The user identifier is written into the second transaction request to determine the third transaction request.

[0125] Optionally, the request body construction module 440 is specifically configured to:

[0126] The request content type of the third transaction request is identified, and the transaction request body is constructed according to the request content type using a preset request body construction method.

[0127] Optionally, the device further includes an audit module;

[0128] The audit module is configured to record an audit log of the third transaction request if the third transaction request complies with a preset transaction request method.

[0129] The transaction code-based application gateway implementation device provided in the embodiment of the present invention can execute the transaction code-based application gateway implementation method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0130] Figure 5 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their modes are only examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0131] like Figure 5As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., which is communicatively connected to the at least one processor 11. The memory stores a computer program that can be executed by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. Various programs and data required for the operation of the electronic device 10 can also be stored in the RAM 13. The processor 11, ROM 12, and RAM 13 are connected to each other via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0132] Multiple components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0133] Processor 11 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any other suitable processor, controller, or microcontroller. Processor 11 executes the various methods and processes described above, such as the transaction code-based application gateway implementation method.

[0134] In some embodiments, the transaction code-based application gateway implementation method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the transaction code-based application gateway implementation method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to execute the transaction code-based application gateway implementation method in any other appropriate manner (e.g., via firmware).

[0135] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0136] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the modes / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0137] In the context of the present invention, computer-readable storage media can be tangible media that can contain or store a computer program for use with an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. Computer-readable storage media can include but are not limited to electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, computer-readable storage media can be machine-readable signal media. More specific examples of machine-readable storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0138] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0139] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or grid browser through which a user can interact with embodiments of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by digital data communication (e.g., a communication grid) in any form or medium. Examples of communication grids include: a local area network (LAN), a wide area network (WAN), a blockchain grid, and the Internet.

[0140] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication grid. This client-server relationship arises through computer programs running on the respective computers, establishing a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within a cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.

[0141] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.

[0142] This embodiment provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the method for implementing a transaction code-based application gateway according to any embodiment of the present invention is implemented. The method includes:

[0143] receiving a first transaction request sent by a user client, pre-processing the first transaction request, and determining a second transaction request;

[0144] obtaining an authentication flag in the second transaction request, authenticating the second transaction request based on the authentication flag, and obtaining the authentication result message;

[0145] If the authentication of the second transaction request is successful, determining a third transaction request based on the authentication result message and the second transaction request;

[0146] Constructing a transaction request body for the third transaction request, and parsing the third transaction request to obtain an interface request address and a transaction request header;

[0147] The transaction request header and the transaction request body are forwarded to the target microservice based on the interface request address.

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

[0149] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device.

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

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

[0152] Those skilled in the art will appreciate that the modules or steps of the present invention described above can be implemented using a general-purpose computing device. They can be centralized on a single computing device or distributed across a grid of multiple computing devices. Alternatively, they can be implemented using program code executable by a computer device, which can then be stored in a storage device and executed by the computing device. Alternatively, they can be fabricated into separate integrated circuit modules, or multiple modules or steps can be fabricated into a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.

[0153] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.

[0154] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.

Claims

1. A method for implementing an application gateway based on a transaction code, characterized in that: include: receiving a first transaction request sent by a user client, pre-processing the first transaction request, and determining a second transaction request; obtaining an authentication flag in the second transaction request, authenticating the second transaction request based on the authentication flag, and obtaining an authentication result message; If the authentication of the second transaction request is successful, determining a third transaction request based on the authentication result message and the second transaction request; Constructing a transaction request body for the third transaction request, and parsing the third transaction request to obtain an interface request address and a transaction request header; The transaction request header and the transaction request body are forwarded to the target microservice based on the interface request address.

2. The method according to claim 1, characterized in that After forwarding the transaction request header and the transaction request body to the target microservice based on the interface request address, the method further includes: Receive a result message returned by the target microservice based on the transaction request header and the transaction request body; A client reply message is generated based on the result message, and the client reply message is sent to the application client.

3. The method according to claim 1, characterized in that The pre-processing of the first transaction request to determine the second transaction request includes: If the first transaction request has a requested transaction code, querying the preset transaction code information table for complete transaction information corresponding to the requested transaction code; Writing the authentication flag in the complete transaction information into the first transaction request, and obtaining the transaction request type of the first transaction request; If the transaction request type of the first transaction request is the same as the transaction request type of the complete transaction information, querying the microservice backend service address corresponding to the first transaction request in a preset microservice backend service address table; The first transaction request is modified based on the microservice backend service address to determine the second transaction request.

4. The method according to claim 3, characterized in that The authenticating the second transaction request based on the authentication flag to obtain the authentication result message includes: If the authentication flag of the second transaction request is a preset authentication value, a preset authentication function is called to authenticate the second transaction request, and an authentication result message returned by the authentication function is obtained.

5. The method according to claim 4, characterized in that The determining, when the second transaction request is successfully authenticated, a third transaction request based on the authentication result message and the second transaction request includes: When the authentication result information in the authentication result message indicates that the authentication is successful, obtaining the user identifier in the authentication result message; The user identifier is written into the second transaction request to determine the third transaction request.

6. The method according to claim 5, characterized in that The step of constructing a transaction request body for the third transaction request includes: The request content type of the third transaction request is identified, and the transaction request body is constructed according to the request content type using a preset request body construction method.

7. The method according to claim 1, characterized in that Also includes: If the third transaction request complies with the preset transaction request method, an audit log of the third transaction request is recorded.

8. An application gateway implementation device based on transaction code, characterized in that: include: a request preprocessing module, configured to receive a first transaction request sent by a user client, preprocess the first transaction request, and determine a second transaction request; an authentication module, configured to obtain an authentication flag bit in the second transaction request, authenticate the second transaction request based on the authentication flag bit, and obtain an authentication result message; a request conversion module, configured to determine a third transaction request based on the authentication result message and the second transaction request if the second transaction request is successfully authenticated; a request body construction module, configured to construct a transaction request body for the third transaction request, and parse the third transaction request to obtain an interface request address and a transaction request header; A forwarding module is used to forward the transaction request header and the transaction request body to a target microservice based on the interface request address.

9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the transaction code-based application gateway implementation method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the transaction code-based application gateway implementation method according to any one of claims 1 to 7 when executed.