CN118283110A - Gateway request message conversion method, device, equipment and medium - Google Patents
Gateway request message conversion method, device, equipment and medium Download PDFInfo
- Publication number
- CN118283110A CN118283110A CN202410379607.9A CN202410379607A CN118283110A CN 118283110 A CN118283110 A CN 118283110A CN 202410379607 A CN202410379607 A CN 202410379607A CN 118283110 A CN118283110 A CN 118283110A
- Authority
- CN
- China
- Prior art keywords
- request
- request message
- conversion configuration
- application system
- system server
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000006243 chemical reaction Methods 0.000 title claims abstract description 254
- 238000000034 method Methods 0.000 title claims abstract description 117
- 230000036541 health Effects 0.000 claims description 21
- 238000004590 computer program Methods 0.000 claims description 4
- 238000004891 communication Methods 0.000 abstract description 15
- 230000004044 response Effects 0.000 abstract description 10
- 238000011161 development Methods 0.000 abstract description 6
- 230000006978 adaptation Effects 0.000 abstract description 5
- 239000008186 active pharmaceutical agent Substances 0.000 description 24
- 238000010586 diagram Methods 0.000 description 20
- 230000004048 modification Effects 0.000 description 6
- 238000012986 modification Methods 0.000 description 6
- 230000008569 process Effects 0.000 description 5
- 230000006870 function Effects 0.000 description 4
- 238000011144 upstream manufacturing Methods 0.000 description 4
- 238000012795 verification Methods 0.000 description 3
- 230000002159 abnormal effect Effects 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 238000007792 addition Methods 0.000 description 1
- 230000008878 coupling Effects 0.000 description 1
- 238000010168 coupling process Methods 0.000 description 1
- 238000005859 coupling reaction Methods 0.000 description 1
- 238000012217 deletion Methods 0.000 description 1
- 230000037430 deletion Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 230000003862 health status Effects 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 238000010926 purge Methods 0.000 description 1
- 238000011160 research Methods 0.000 description 1
- 238000000926 separation method Methods 0.000 description 1
- 239000000126 substance Substances 0.000 description 1
- 230000009466 transformation Effects 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/56—Provisioning of proxy services
- H04L67/565—Conversion or adaptation of application format or content
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/60—Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
- H04L67/63—Routing a service request depending on the request content or context
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer And Data Communications (AREA)
Abstract
The application provides a gateway request message conversion method, a device, equipment and a medium, which can determine request message conversion configuration corresponding to an application system server according to a first request message, convert relevant parts in the first request message into a format corresponding to the application system server by utilizing the request message conversion configuration, dynamically convert the request message by an API gateway, ensure that the request message of an application system client can be accurately forwarded to the corresponding server and simultaneously access different service interfaces to obtain different response results, obviously reduce development workload of the client and the server, improve the flexibility of communication between the client and the server, realize various access application scenes such as cross-domain access, load balancing, safety control and the like, improve the flexible adaptability of the API gateway to various heterogeneous client and server combinations, and realize communication message adaptation between the application system client and the application system server.
Description
Technical Field
The present application relates to the field of computers, and in particular, to a method, an apparatus, a device, and a medium for converting a gateway request message.
Background
With popularization and vigorous development of internet technology, technologies such as micro services, cloud protogenesis, HTML5 and the like continue to evolve, and abundant and various service realization scenes appear, so that many technical problems are needed to be solved. Currently, mobile communication and financial fields are deeply converged, and mobile application becomes a main access channel of bank clients. An application programming interface (Application Programming Interface, API) gateway is an indispensable key ring in a micro-service architecture, is a unified entry for connecting a client and a server, and is used for uniformly controlling the flow between the client and the server, so that the call of the client to the server is simplified, the working cost of the server is reduced, and the loose coupling of a system is promoted.
However, how to adapt to various terminals and connect heterogeneous service ends while ensuring the safety and reliability of the API gateway is an important problem worthy of intensive research. In actual service, the same client can access different server APIs through different request paths, meanwhile, the same server APIs can also return different responses according to different request messages, so that great amount of modification or code redundancy is often required to be carried out on the client and the server to achieve the effects, and development workload of the client and the server is great. Therefore, providing a suitable gateway request message conversion method is an urgent technical problem to be solved at present.
Disclosure of Invention
In view of the above, the present application aims to provide a gateway request message conversion method, device, equipment and medium, which can significantly reduce the development workload of clients and servers, improve the flexible adaptability of an API gateway to various heterogeneous client and server combinations, satisfy the diversified function requirements of an application system, and realize the adaptation of communication messages between an application system client and an application system server. The specific scheme is as follows:
In one aspect, the present application provides a gateway request message conversion method, which is applied to an API gateway, and the method includes:
Receiving a first request message sent by an application system client to an application system server, wherein the first request message comprises a first request header, a first request path, a first request method, a first request character code and a first request data type;
Determining request message conversion configuration matched with the application system server according to the first request message; the request message conversion configuration comprises at least one of request header conversion configuration, request query parameter conversion configuration, request path conversion configuration, request method conversion configuration, request character code conversion configuration or request data type conversion configuration;
And converting the first request message according to the request message conversion configuration to obtain a second request message matched with the application system server, and sending the second request message to the application system server.
In still another aspect, an embodiment of the present application further provides a gateway request packet conversion device, which is applied to an API gateway, including:
The receiving unit is used for receiving a first request message sent by the application system client to the application system server, wherein the first request message comprises a first request head, a first request path, a first request method, a first request character code and a first request data type;
the determining unit is used for determining request message conversion configuration matched with the application system server according to the first request message; the request message conversion configuration comprises at least one of request header conversion configuration, request query parameter conversion configuration, request path conversion configuration, request method conversion configuration, request character code conversion configuration or request data type conversion configuration;
And the sending unit is used for converting the first request message according to the request message conversion configuration to obtain a second request message matched with the application system server and sending the second request message to the application system server.
In yet another aspect, an embodiment of the present application provides a computer device including a processor and a memory:
the memory is used for storing program codes and transmitting the program codes to the processor;
the processor is configured to perform the method of the above aspect according to instructions in the program code.
In yet another aspect, embodiments of the present application provide a computer-readable storage medium for storing a computer program for performing the method described in the above aspect.
The embodiment of the application provides a gateway request message conversion method, a device, equipment and a medium, wherein the method is applied to an API gateway, and the API gateway receives a first request message sent by an application system client to an application system server, wherein the first request message comprises a first request header, a first request path, a first request method, a first request character code and a first request data type; determining a request message conversion configuration matched with the application system server according to the first request message, wherein the request message conversion configuration can be used for converting the first request message into a message format matched with the application system server, the request message conversion configuration can comprise at least one of request header conversion configuration, request query parameter conversion configuration, request path conversion configuration, request method conversion configuration, request character code conversion configuration or request data type conversion configuration, converting the first request message according to the request message conversion configuration to obtain a second request message matched with the application system server, and sending the second request message to the application system server.
That is, according to the first request message, the request message conversion configuration corresponding to the application system server can be determined, the relevant part in the first request message is converted into the format corresponding to the application system server by using the request message conversion configuration, that is, the format is converted into the second request message, so that the API gateway can dynamically convert the request message, ensure that the request message of the application system client can be accurately forwarded to the corresponding server, access different service interfaces, obtain different response results, remarkably reduce the development workload of the client and the server, improve the flexibility of communication between the client and the server, realize various access application scenarios such as cross-domain access, load balancing, safety control and the like, improve the flexible adaptability of the API gateway to various heterogeneous client and server combinations, meet the diversified function requirements of the application system, and realize the adaptation of the communication message between the application system client and the application system server.
Drawings
In order to more clearly illustrate the embodiments of the application or the technical solutions in the prior art, the drawings that are needed in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are some embodiments of the application and that other drawings may be obtained from these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic flow chart of a gateway request message conversion method according to an embodiment of the present application;
FIG. 2 shows a schematic diagram of a control unit according to an embodiment of the present application;
FIG. 3 is a flowchart of determining a request message conversion configuration according to an embodiment of the present application;
Fig. 4 shows a schematic diagram of a conversion unit according to an embodiment of the present application;
FIG. 5 is a schematic diagram of a request message conversion according to an embodiment of the present application;
fig. 6 is a schematic diagram of a conversion flow of a request packet according to an embodiment of the present application;
fig. 7 shows a schematic diagram of a forwarding unit according to an embodiment of the present application;
fig. 8 is a schematic diagram of a forwarding flow of a second request packet according to an embodiment of the present application;
Fig. 9 is an overall schematic diagram of a gateway request packet conversion system according to an embodiment of the present application;
fig. 10 is a schematic diagram of another gateway request packet conversion according to an embodiment of the present application;
Fig. 11 is a block diagram of a gateway request message conversion device according to an embodiment of the present application;
Fig. 12 is a block diagram of a computer device according to an embodiment of the present application.
Detailed Description
In order that the above objects, features and advantages of the application will be readily understood, a more particular description of the application will be rendered by reference to the appended drawings.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application, but the present application may be practiced in other ways other than those described herein, and persons skilled in the art will readily appreciate that the present application is not limited to the specific embodiments disclosed below.
In order to facilitate understanding, the following describes in detail a gateway request message conversion method, device, equipment and medium provided in the embodiments of the present application with reference to the accompanying drawings.
Referring to fig. 1, a flow chart of a gateway request message conversion method according to an embodiment of the present application is applied to an API gateway, and the method may include the following steps.
S101, receiving a first request message sent by an application system client to an application system server.
In the embodiment of the application, when the application system client sends the first request message to the application system server, the API gateway can receive the first request message so as to perform format conversion on the first request message and accord with the format of the application system server.
The first request message may include a first request header, a first request path, a first request method, a first request character encoding, and a first request data type. The application system may be, for example, a palm banking system, where the application system client may be a terminal device for loading the palm banking system, such as a mobile phone, and the application system server may be a back end server of the palm banking system.
S102, determining request message conversion configuration matched with the application system server according to the first request message.
Specifically, the first request message may embody related information of the application system client and related information of the application system server, and according to the first request message, a message receiver, that is, the application system server, may be determined, and a request message conversion configuration corresponding to the application system server may be queried, where the request message conversion configuration is used to convert the first request message into a message format conforming to the corresponding application system server.
In one possible implementation manner, the request message conversion configuration matched with the application system server is determined according to the first request message, that is, the corresponding application system server is determined according to the first request message, and the request message conversion configuration matched with the application system server is determined according to the application system server.
The request message conversion configuration may include at least one of a request header conversion configuration, a request query parameter conversion configuration, a request path conversion configuration, a request method conversion configuration, a request character code conversion configuration, or a request data type conversion configuration, for example, the application system server a needs to perform the request header conversion configuration and the request character code conversion configuration on the request message, and the application system server B needs to perform all conversion configurations on the request message.
Specifically, the method may be executed by using a gateway request message conversion system, where the gateway request message conversion system may include a control unit, a conversion unit, and a forwarding unit, and referring to fig. 2, a schematic diagram of a control unit provided in an embodiment of the present application is shown, where the control unit includes a permission controller, a request dynamic conversion controller, a configuration checker, and a configuration pusher, and the control unit mainly controls a user permission and a request message conversion configuration, checks the request message conversion configuration of the user configuration that passes the permission check, and pushes the request message conversion configuration that passes the check to the conversion unit.
Referring to fig. 3, a flowchart for determining a request message conversion configuration is provided in an embodiment of the present application, where the authority controller may verify the authority of a user, and when a request for the request message conversion configuration is received, that is, when a first request message is received, the authority controller verifies the authority of the user, and verifies the authority of an application system client and a user according to the content in the first request message.
After the user authority verification is successful, the request dynamic conversion controller can dynamically control each component part of the first request message: request methods, request header, request query parameters, request body, etc. And the character set and the data format of the request message can be controlled, namely the conversion configuration of the request message is determined. The configuration checker comprises a check set and a checker, and is used for checking the determined request message conversion configuration, and after the check is successful, the configuration pusher pushes the request message conversion configuration which is checked to be successful to the conversion unit, so that the determination operation of the request message conversion configuration is completed.
S103, converting the first request message according to the request message conversion configuration to obtain a second request message matched with the application system server, and sending the second request message to the application system server.
In the embodiment of the application, the request message conversion configuration can be used for realizing configuration conversion, and the request message conversion configuration can include format information corresponding to an application system server, for example, the request message conversion configuration can include a target request header, a target request path, a target request method, a target request character code or a target request data type, and the like, so that a corresponding part in a first request message is subjected to message format conversion to obtain a second request message, and the message format of the second request message is matched with the application system server, so that the first request message with the message format of an application system client is converted into the second request message conforming to the message format of the application system server by utilizing the request message conversion configuration corresponding to the application system server.
The API gateway sends the second request message to the application system server, so that the request message sent to the application system server accords with the message format, the application system client and the application system server can normally communicate, the condition that the application system server cannot analyze the message sent by the application system client due to inconsistent message formats is avoided, the API gateway can realize conversion of the message formats, development workload of the client and the server is obviously reduced, and the flexibility of communication between the client and the server is improved.
And when the corresponding request message conversion configuration is configured for various application system clients or various service interfaces in advance, the communication with various application system clients or service interfaces can be realized, the request message of the application system client can be ensured to be accurately forwarded to the corresponding service end, different service interfaces can be accessed to obtain different response results, various access application scenes such as cross-domain access, load balancing and the like can be realized, the flexible suitability of the API gateway for various heterogeneous client and service end combinations is improved, and the diversified function requirements of the application system are met.
In a possible implementation manner, before the request message conversion configuration is utilized to convert the first request message, the request message conversion configuration may be further parsed, so as to obtain a parsed request message conversion configuration, and referring to fig. 4, a schematic diagram of a conversion unit provided in an embodiment of the present application is shown, where the conversion unit includes a configuration parser, a configuration manager, and a request dynamic converter, and the conversion unit mainly receives and processes the request message conversion configuration pushed by the control unit, parses the request message conversion configuration into a format that can be recognized by the conversion unit, for example, into a json form composed of key value pairs that can be recognized by the conversion unit, stores and manages the parsed request message conversion configuration, and dynamically converts the first request message according to the parsed request message conversion configuration. Referring to fig. 5, a schematic diagram of request message conversion according to an embodiment of the present application is shown.
The configuration parser may include a receiver and a parser, where the receiver is configured to receive the request message conversion configuration sent by the control unit, and the parser parses the request message conversion configuration sent by the control unit into a data form that can be identified by the conversion unit according to a rule set predefined by the API gateway.
The configuration manager comprises a memory and a manager, wherein the memory is used for storing the analyzed request message conversion configuration, the manager is provided for a gateway manager or an application manager to manage the request message conversion configuration, and the stored request message conversion configuration is subjected to management operations such as addition, deletion, modification, check and the like, so that customization of the request message conversion configuration is realized.
The request dynamic converter is mainly used for realizing the dynamic conversion of a first request message, sending the application system client to the first request message of the API gateway, carrying out dynamic conversion according to the request message conversion configuration in the memory configured by the API gateway, and converting the request message conversion configuration into a message form required by the application system server, thereby flexibly adapting to various service scenes and ensuring that the application system server can normally respond to the request sent to the API gateway according to the requirement.
In one possible implementation, the request methods include a request method with a request body, such as a POST, PUT, etc., and a request method without a request body, such as a GET, DELETE, etc.
Specifically, the first request method may be a request method with a request body, and the application system server adapts to a request method without a request body, and the request message conversion configuration corresponding to the application system server includes a request method conversion configuration and a request query parameter conversion configuration, that is, the application system server needs to perform conversion of the request method and the request query parameter on the first request message, then S103 may include the following steps.
Specifically, the request method dynamic converter can utilize the request method conversion configuration to realize the conversion of the request method, and the request method dynamic converter can dynamically convert the request method among the application system client, the gateway and the application system server, and can convert among a plurality of common request methods such as GET, POST, PUT, DELETE. In the situation that a request method such as POST, PUT and the like carrying request body data types is mutually converted with a non-request body method such as GET, DELETE and the like, the method conversion is carried out, meanwhile, the request data is converted between a query character string and a request body, and the safe conversion of the request method is ensured.
Because the first request method of the first request message has the request body, the request body data can be extracted from the first request message, the request body data is converted into the query parameters according to the request query parameter conversion configuration, and the query parameters are spliced after the first request path.
The request query parameter dynamic converter can be used for converting the query parameters, the request query parameter dynamic converter can put parameters in a request body into a query, convert a json format key value pair in the request body into a query character string, splice the query character string to the rear side of a request path, and convert { "k1": v1, "k2": v2} into a http:// host: port/interfacek 1=v1 & k2=v2. Likewise, the query string in the request path may in turn be translated into data in the request body.
The request query parameter dynamic converter defaults to put all parameters in the request body into the query, and can also specify the parameters to be put into the query. The general request query parameter dynamic converter is used together with the request method dynamic converter, and the request query parameter dynamic converter can realize that the request data is not lost while the request method is converted. For example, when the request methods such as POST, PUT and the like carrying the request body data types are converted into the non-request methods such as GET, DELETE and the like, the request body data can be transferred into the query parameters, and the request data is not lost.
In addition, according to the request method conversion configuration, the first request method is converted into a second request method, the second request method is a request method without a request body, and the second request message comprises the second request method. Therefore, when the request method carrying the request body is converted into the request method without the request, the data in the request body is not lost, the request body data is converted into the query parameter and is placed behind the request path, the request method is converted according to the requirement of the application system server, and the application system server and the application system client are not required to be improved greatly, so that normal communication between the application system server and the application system client is realized.
The dynamic converter of the request method can meet various scenes such as encryption and decryption of request response messages, communication anti-counterfeiting and the like, for example, a non-request body method of a client side wants to realize the function of encrypting and decrypting the messages through a gateway, but because the size of a query character string is limited, ciphertext cannot be completely placed in a request path, the request method is required to be converted into a request method with a request body, the encrypted messages are placed in the request body, and the gateway can be applied to a safety control scene through encryption and decryption operation.
In another possible implementation manner, the request message conversion configuration corresponding to the application system server may further include a request data type conversion configuration, and then the request body data is extracted from the first request message, and the request body data is converted into the query parameter according to the request query parameter conversion configuration, which may specifically include the following steps.
Specifically, the request body data can be extracted from the first request message, the request body data is converted by using the request data type dynamic converter according to the request data type conversion configuration, so as to obtain the request body data with the target request data type, the request data type dynamic converter can convert the first request message sent by the application system client to the gateway into the data type (such as form-data, urlencoded, json) which can be received by the application system server, so that the communication specification adaptation between the front end and the rear end of the application system is realized, and the front end and the rear end separation of the application system is helped. Then, according to the request parameter conversion configuration, the request body data with the target request data type is converted into the request parameter.
In another possible implementation, when the request message conversion configuration includes a request path conversion configuration, S103 may specifically include the following steps.
Specifically, a request path dynamic converter can be utilized to replace a domain name and a port number in a first request path with a network address of an application system server according to request path conversion configuration, and splice the network address with a routing path corresponding to a target interface (Application Programming Interface, API) corresponding to the application system server to obtain a second request path matched with the application system server; the second request message includes a second request path.
That is, the request path dynamic converter may replace the domain name and the port number of the first request path sent to the gateway with the network address corresponding to the service end of the upstream application system according to the forwarding route configuration in the memory of the configuration manager, replace the rest of the first request path with the route path configured by the target interface in the gateway service, splice the two to obtain a new request path, and obtain a second request path, where the second request path meets the path format requirement of the service end of the application system.
In addition, the dynamic conversion of the request path can be realized by configuring the occupation parameter in the request path, and the same request can obtain multiple responses. For example, there is ((id)) in the request path, a key value pair with the key "id" is found in the request body, and the value is filled in, that is, the occupation parameter can be configured in the request path, when the application system server side sends the first message request to the application system client side, the occupation parameter in the request path can be replaced by the parameter corresponding to the application system client side, so as to generate the first request path.
In the embodiment of the application, the message conversion can be performed according to the specific configuration in the request message conversion configuration, wherein the more representative process is the request method dynamic conversion process, and the request message conversion process is often used in combination with a request method dynamic converter, a request query parameter dynamic converter, a request data type dynamic converter and the like, so that the dynamic conversion of the request message is realized, and the rich service scene of the application system client side and the application system server side is satisfied.
Referring to fig. 6, a schematic diagram of a conversion flow of a request message according to an embodiment of the present application is shown, where a gateway may determine whether a first request method needs to be dynamically converted according to a request message conversion configuration, and if not, directly request conversion of other parts according to the request message conversion configuration. If the request method needs to be dynamically converted, judging whether the target request method in the configuration is GET, HEAD, COPY, PURGE, UNLOCK, TRACE or not according to the request message conversion configuration, or whether the configuration designates that the request volume data needs to be put into the query, if so, extracting the request volume data, dynamically converting and analyzing the request volume data according to the request data type conversion configuration (urlencoded, json, form-data), converting the request volume data into a query parameter (for example, converting a json-form k: v key value pair into a form k1=v1 & k2=v2), dynamically converting a request path according to the query parameter, and finally converting other parts of the request according to the configuration, and forwarding the request to an application system server. If the above situation is not met, only the request data type conversion and other partial conversion are required. The server of the final application system can receive the second request message conforming to the message format of the server and return the corresponding response result to the client of the application system, the reconstruction workload of the client code can be reduced through request conversion, the purposes of accessing different interfaces of the server or obtaining different response results can be achieved through the request message conversion configuration of the gateway, and the communication efficiency is improved.
In another possible implementation manner, when the request packet conversion configuration includes a request header conversion configuration, S103 may specifically be that, using a request header dynamic converter, according to the request header conversion configuration, a field and a field value of a first request header are converted to obtain a second request header matched with the application system server, where the second request packet includes the second request header.
Specifically, the request header dynamic converter can dynamically add, delete and modify the request header fields and the corresponding field values according to the request header conversion configuration, so as to adapt to the situation that the request sent by the application system client is dynamically forwarded to different application system servers, and can realize the application scenarios such as the dynamic configuration cross-domain request, the load balancing and the like, and realize the conversion of the request header data format through the API gateway, thereby meeting the communication message conversion between heterogeneous clients and servers and realizing the normal communication.
In another possible implementation manner, when the request message conversion configuration includes a request character code conversion configuration, S103 may specifically be that, with a request data type dynamic converter, according to the request character code conversion configuration, the first request character code is converted to obtain a second request character code matched with the application system server; the second request message includes a second request character encoding.
Specifically, the request character coding dynamic converter can convert the first request message according to different character codes (UTF-8, GBK, ASCII, GB2312, etc.) according to the requirements of the application system server, so as to adapt to the character code specifications of the communication messages between various devices or platform clients and the server, and reduce the adaptation and transformation workload of the application system.
In another possible implementation manner, the API gateway sends the second request packet to the application system server, which may specifically be performing health check on the application system server, and if the health check passes, sending the second request packet to the application system server.
Specifically, referring to fig. 7, a schematic diagram of a forwarding unit according to an embodiment of the present application includes a health checker, a request parser, and a request forwarder, where the forwarding unit mainly parses a second request packet converted by the conversion unit, determines an address of a corresponding service end of an application system according to the parsed second request packet, performs health checking on the address, fuses a service when the service of the application system is unhealthy, and forwards the second request packet if the service is healthy.
Referring to fig. 8, a schematic forwarding flow diagram of a second request packet according to an embodiment of the present application is shown, where the request parser includes a rule set and a parser, the request parser parses the converted second request packet according to a certain rule, and the health checker is configured to detect whether an application system server of the access gateway is normal, and blow a service when the application system server is unhealthy.
The health examination can be performed by using an active health inspector, the gateway can periodically and actively request the application system server, analyze the health condition of the application system server according to the service response and process the health condition, and automatically disable the target if the service is judged to be in an unhealthy state; if it is determined that the service has recovered from health, this goal is re-automatically enabled. The health check can also utilize a passive health checker, the gateway uses a breaker mode to automatically disable unhealthy targets by analyzing the proxied real-time traffic, determining the health status of the targets according to the custom configuration and target response status in the health check.
The request forwarder mainly comprises a router and a forwarder, wherein the router matches corresponding routes according to the configuration of the second request message after conversion and analysis and the application system in the gateway service, and the request forwarder forwards the second request message after analysis to the corresponding application system service end according to the corresponding route paths, so that the forwarding of the request message is realized.
In the embodiment of the present application, referring to fig. 9, an overall schematic diagram of a gateway request message conversion system provided by the embodiment of the present application is shown, referring to fig. 10, and referring to another schematic diagram of gateway request message conversion provided by the embodiment of the present application, dynamic conversion of gateway request messages can be implemented by flexibly configuring request message conversion configuration for a gateway, and multiple communication specifications between a client and a server are adapted.
The control unit is mainly used for controlling the application system to dynamically configure the corresponding request message conversion configuration in the gateway service and sending the configuration to the conversion unit; the conversion unit is mainly used for converting the application system request according to the configuration pushed by the control unit, and comprises the steps of receiving, analyzing, managing and dynamically converting the request message conversion configuration of the application system configuration; the forwarding unit analyzes the converted request message, performs health check on the upstream application system service, and forwards the converted request message to the upstream application system service.
The control unit dynamically controls the request message conversion configuration of the application system, carries out configuration verification on the request message conversion configuration configured by the user passing the authority verification, and pushes the verified request message conversion configuration to the conversion unit.
The conversion unit receives the request message conversion configuration pushed by the control unit, performs configuration analysis, analyzes the received request message conversion configuration, stores and manages the analyzed result through the configuration manager, converts the application system request message according to the analyzed request message conversion configuration, and finally sends the converted request message to the forwarding unit.
The forwarding unit firstly analyzes the converted request message sent by the conversion unit, and carries out health check on the corresponding application system service node according to the analyzed result. If the health check is abnormal, the system is sent to a conversion unit for configuration updating, then request conversion is carried out again, and if the system is unhealthy, the system service is actively fused; if the health check is abnormal, the converted request message is forwarded to the corresponding upstream application system server.
Based on the above gateway request message conversion method, the embodiment of the present application further provides a gateway request message conversion device, and referring to fig. 11, a structural block diagram of the gateway request message conversion device provided by the embodiment of the present application is applied to an API gateway, where the device may include:
a receiving unit 201, configured to receive a first request packet sent by an application system client to an application system server, where the first request packet includes a first request header, a first request path, a first request method, a first request character code, and a first request data type;
a determining unit 202, configured to determine, according to the first request message, a request message conversion configuration matched with the application system server; the request message conversion configuration comprises at least one of request header conversion configuration, request query parameter conversion configuration, request path conversion configuration, request method conversion configuration, request character code conversion configuration or request data type conversion configuration;
The sending unit 203 is configured to convert the first request message according to the request message conversion configuration, obtain a second request message matched with the application system server, and send the second request message to the application system server.
Optionally, the first request method is a request method with a request body, and the request message conversion configuration includes the request method conversion configuration and the request query parameter conversion configuration;
The transmitting unit is used for:
Extracting request body data from the first request message, converting the request body data into a query parameter according to the request query parameter conversion configuration, and splicing the query parameter after the first request path;
And converting the first request method into a second request method according to the request method conversion configuration, wherein the second request method is a request method without a request body, and the second request message comprises the second request method.
Optionally, the request message conversion configuration further includes a request data type conversion configuration, and the sending unit is configured to:
Extracting the request volume data from the first request message;
converting the request volume data according to the request data type conversion configuration to obtain request volume data with a target request data type;
And converting the request body data with the target request data type into the query parameters according to the request query parameter conversion configuration.
Optionally, when the request packet conversion configuration includes the request path conversion configuration, the sending unit is configured to:
according to the request path conversion configuration, replacing the domain name and the port number in the first request path with the network address of the application system server;
splicing the network address and the routing path corresponding to the application system server to obtain a second request path matched with the application system server; the second request message includes the second request path.
Optionally, when the request message conversion configuration includes a request header conversion configuration, the sending unit is configured to:
converting the field and the field value of the first request header according to the request header conversion configuration to obtain a second request header matched with the application system server, wherein the second request message comprises the second request header;
And/or the number of the groups of groups,
When the request message conversion configuration includes a request character transcoding configuration, the sending unit is configured to:
Converting the first request character code according to the request character code conversion configuration to obtain a second request character code matched with the application system server; the second request message includes the second request character code.
Optionally, the determining unit is configured to:
Determining a corresponding application system server according to the first request message;
and determining the request message conversion configuration matched with the application system server according to the application system server.
Optionally, the sending unit is configured to:
And carrying out health check on the application system server, and if the health check passes, sending the second request message to the application system server.
In yet another aspect, referring to fig. 12, a block diagram of a computer device according to an embodiment of the present application is provided, where the computer device includes a processor 310 and a memory 320:
the memory 320 is used for storing program codes and transmitting the program codes to the processor 310;
the processor 310 is configured to execute the method provided in the above embodiment according to the instructions in the program code.
The computer device may comprise a terminal device or a server, in which the aforementioned means may be arranged.
In yet another aspect, an embodiment of the present application further provides a storage medium, where the storage medium is used to store a computer program, where the computer program is used to execute the method provided in the foregoing embodiment.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the above method embodiments may be implemented by program instruction hardware, and the above program may be stored in a computer readable storage medium, where the program when executed performs steps including the above method embodiments; and the aforementioned storage medium may be at least one of the following media: read-only Memory (ROM), RAM, magnetic disk or optical disk, etc.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments for relevant points.
The foregoing is merely a preferred embodiment of the present application, and the present application has been disclosed in the above description of the preferred embodiment, but is not limited thereto. Any person skilled in the art can make many possible variations and modifications to the technical solution of the present application or modifications to equivalent embodiments using the methods and technical contents disclosed above, without departing from the scope of the technical solution of the present application. Therefore, any simple modification, equivalent variation and modification of the above embodiments according to the technical substance of the present application still fall within the scope of the technical solution of the present application.
Claims (10)
1. A gateway request message conversion method, which is applied to an API gateway, the method comprising:
Receiving a first request message sent by an application system client to an application system server, wherein the first request message comprises a first request header, a first request path, a first request method, a first request character code and a first request data type;
Determining request message conversion configuration matched with the application system server according to the first request message; the request message conversion configuration comprises at least one of request header conversion configuration, request query parameter conversion configuration, request path conversion configuration, request method conversion configuration, request character code conversion configuration or request data type conversion configuration;
And converting the first request message according to the request message conversion configuration to obtain a second request message matched with the application system server, and sending the second request message to the application system server.
2. The method of claim 1, wherein the first request method is a request method having a requestor, the request message conversion configuration comprising the request method conversion configuration and the request query parameter conversion configuration;
The method for adapting the application system server to the request without the request body includes that the first request message is converted according to the request message conversion configuration to obtain a second request message matched with the application system server, and the method includes the steps of:
Extracting request body data from the first request message, converting the request body data into a query parameter according to the request query parameter conversion configuration, and splicing the query parameter after the first request path;
And converting the first request method into a second request method according to the request method conversion configuration, wherein the second request method is a request method without a request body, and the second request message comprises the second request method.
3. The method of claim 2, wherein the request message conversion configuration further comprises a request data type conversion configuration, wherein the extracting request body data from the first request message and converting the request body data into a query parameter according to the request query parameter conversion configuration comprises:
Extracting the request volume data from the first request message;
converting the request volume data according to the request data type conversion configuration to obtain request volume data with a target request data type;
And converting the request body data with the target request data type into the query parameters according to the request query parameter conversion configuration.
4. A method according to any one of claims 1-3, wherein when the request message conversion configuration includes the request path conversion configuration, the converting the first request message according to the request message conversion configuration to obtain a second request message matched with the application server includes:
according to the request path conversion configuration, replacing the domain name and the port number in the first request path with the network address of the application system server;
Splicing the network address and the routing path corresponding to the target interface of the application system server to obtain a second request path matched with the application system server; the second request message includes the second request path.
5. The method according to claim 1, wherein when the request message conversion configuration includes a request header conversion configuration, the converting the first request message according to the request message conversion configuration to obtain a second request message matched with the application system server includes:
converting the field and the field value of the first request header according to the request header conversion configuration to obtain a second request header matched with the application system server, wherein the second request message comprises the second request header;
And/or the number of the groups of groups,
When the request message conversion configuration includes a request character code conversion configuration, the converting the first request message according to the request message conversion configuration to obtain a second request message matched with the application system server, including:
Converting the first request character code according to the request character code conversion configuration to obtain a second request character code matched with the application system server; the second request message includes the second request character code.
6. The method of claim 1, wherein determining a request message conversion configuration matching the application system server according to the first request message comprises:
Determining a corresponding application system server according to the first request message;
and determining the request message conversion configuration matched with the application system server according to the application system server.
7. The method of claim 1, wherein the sending the second request message to the application server includes:
And carrying out health check on the application system server, and if the health check passes, sending the second request message to the application system server.
8. The gateway request message conversion device is characterized by being applied to an API gateway and comprising:
The receiving unit is used for receiving a first request message sent by the application system client to the application system server, wherein the first request message comprises a first request head, a first request path, a first request method, a first request character code and a first request data type;
the determining unit is used for determining request message conversion configuration matched with the application system server according to the first request message; the request message conversion configuration comprises at least one of request header conversion configuration, request query parameter conversion configuration, request path conversion configuration, request method conversion configuration, request character code conversion configuration or request data type conversion configuration;
And the sending unit is used for converting the first request message according to the request message conversion configuration to obtain a second request message matched with the application system server and sending the second request message to the application system server.
9. A computer device, the computer device comprising a processor and a memory:
the memory is used for storing program codes and transmitting the program codes to the processor;
the processor is configured to perform the method of any of claims 1-7 according to instructions in the program code.
10. A computer readable storage medium, characterized in that the computer readable storage medium is for storing a computer program for executing the method of any one of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410379607.9A CN118283110A (en) | 2024-03-29 | 2024-03-29 | Gateway request message conversion method, device, equipment and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410379607.9A CN118283110A (en) | 2024-03-29 | 2024-03-29 | Gateway request message conversion method, device, equipment and medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN118283110A true CN118283110A (en) | 2024-07-02 |
Family
ID=91649276
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410379607.9A Pending CN118283110A (en) | 2024-03-29 | 2024-03-29 | Gateway request message conversion method, device, equipment and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN118283110A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN119316481A (en) * | 2024-12-16 | 2025-01-14 | 宁波港信息通信有限公司 | Service request processing method and device |
-
2024
- 2024-03-29 CN CN202410379607.9A patent/CN118283110A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN119316481A (en) * | 2024-12-16 | 2025-01-14 | 宁波港信息通信有限公司 | Service request processing method and device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP4363847B2 (en) | Digital TV application protocol for interactive TV | |
KR100205954B1 (en) | Relay server for virtual banking service and its service method | |
CN110020955B (en) | Online medical insurance information processing method and device, server and user terminal | |
HU223910B1 (en) | Method of transmitting information data from a sender to a reciever via a transcoder, method of transcoding information data, method of receiving transcoded information data, sender, receiver and transcoder | |
CN108769743B (en) | Video playing control method, system, node and computer storage medium | |
CN114828140B (en) | Service flow message forwarding method and device, storage medium and electronic equipment | |
CN106844489A (en) | A kind of file operation method, device and system | |
CN112187491A (en) | Server management method, device and equipment | |
CN113556359B (en) | Communication protocol conversion method, device, system and gateway device | |
CN118283110A (en) | Gateway request message conversion method, device, equipment and medium | |
CN114978888A (en) | A message forwarding method, device, electronic device and storage medium | |
CN110545230A (en) | method and device for forwarding VXLAN message | |
CN110913011B (en) | Session holding method, session holding device, readable storage medium and electronic device | |
CN114710311B (en) | Multi-project message management method and system | |
CN105812380A (en) | Verification method and device | |
CN106789987B (en) | Method and system for single sign-on of multi-service interconnection APP (application) of mobile terminal | |
CN104065688B (en) | A kind of method and device for calling underlying services | |
CN109547281B (en) | Tor network tracing method | |
CN110650014B (en) | Signature authentication method, system, equipment and storage medium based on hessian protocol | |
CN114301967A (en) | Narrow-band Internet of things control method, device and equipment | |
CN104753774A (en) | A Distributed Enterprise Integrated Access Gateway | |
CN116208544B (en) | Message sending method, system, device, equipment and storage medium | |
CN118171297A (en) | Interface authority control method and device, storage medium and electronic equipment | |
CN115361455B (en) | Data transmission storage method and device and computer equipment | |
CN112069292B (en) | Data permission verification method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |