Interface maintenance method, device, electronic device and storage medium
By generating and publishing multi-terminal interface code, the consistency of interface information is ensured, the problems of interface development code consistency and security in the existing technology are solved, and the security and efficiency of interface calling are improved.
Patent Information
- Application Number
- CN202210260037.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-16
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2042-03-16
AI Technical Summary
The existing interface development process lacks a consistency guarantee mechanism for the interface development code between each end, which affects the normal communication between the server and the client and reduces the security of the interface calling process.
By generating multi-end interface code based on local interface information and publishing it to the gateway, it ensures that the gateway verifies the interface access request sent by the client and the parameter information of the returned result, ensuring the consistency of the interface information, thereby improving the security of interface calls. sex.
It achieves the consistency of the interface development code at each end and the real-time update of the interface information, improves the security and efficiency of interface calls, and ensures normal communication between the server and the client.
Smart Images

Figure CN114465892B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to an interface maintenance method, device, electronic device, and computer-readable storage medium. Background Art
[0002] Application Programming Interface (API) is a set of predefined interfaces (such as functions, HTTP interfaces, etc.), or refers to the agreements for connecting different components of a software system. The API interface can be used to achieve mutual communication between computer software.
[0003] At present, in the existing interface development process, there is a lack of consistency guarantee mechanism for interface development codes between each end (server and client). In addition, during the interface launch phase of each end, there is a lack of consistency guarantee mechanism for online traffic data and interface information in the interface design phase, which will not only affect the normal communication between the server and the client, but also reduce the security of the interface call process. Summary of the invention
[0004] The embodiments of the present disclosure at least provide an interface maintenance method, an interface maintenance device, an electronic device, and a computer-readable storage medium to ensure the consistency between the interface information published on the gateway and the local interface information, thereby improving the security of interface calls.
[0005] The present disclosure provides an interface maintenance method, including:
[0006] Based on the local interface information, generating a multi-terminal interface code corresponding to the local interface information; the multi-terminal interface code includes a client interface code, which is used to implement the function corresponding to the local interface information on the client;
[0007] The local interface information is published to a gateway, so that the gateway verifies the parameter information of the interface access request sent by the client based on the parameter information of the local interface information, wherein the interface access request is generated based on the client interface code.
[0008] In the disclosed embodiment, multi-terminal interface codes are generated based on local interface information to ensure the consistency of interface development codes between the terminals; and the local interface information is published to the gateway, so that the consistency of the interface information published on the gateway and the local interface information can be ensured, thereby improving the security of interface calls.
[0009] In an optional implementation manner, the multi-terminal interface code further includes a server interface code; after publishing the local interface information to the gateway, the method further includes:
[0010] In response to the interface access request sent by the gateway and based on parameter information of the interface access request, execute the server interface code corresponding to the local interface information corresponding to the interface access request, and generate a return result corresponding to the interface access request;
[0011] The returned result is sent to a gateway, so that the gateway verifies the parameter information of the returned result based on the parameter information of the local interface information.
[0012] In the disclosed embodiment, by sending the return result to the gateway, the return result can be verified at the gateway, and the consistency of the return result generated by the server-side response interface access question and the parameter information of the local interface information can be ensured.
[0013] In an optional implementation manner, the interface access request carries target access service information; and the executing, based on the parameter information of the interface access request, the server interface code corresponding to the local interface information corresponding to the interface access request includes:
[0014] Determining local service interface information based on the target access service information;
[0015] Based on the local service interface information, the server interface code corresponding to the local interface information corresponding to the interface access request is executed.
[0016] In the disclosed embodiment, the local service interface information is determined through the target access service information, thus narrowing the scope of determination, thereby saving time cost and improving the efficiency of verification.
[0017] In an optional implementation manner, before generating a multi-terminal interface code corresponding to the local interface information based on the local interface information, the method further includes:
[0018] Based on the interface description language, the parameter information of the local interface is defined to generate the local interface information; the local interface information is stored in the GIT warehouse.
[0019] In the disclosed embodiment, since the interface description language has clear semantics and a simple structure, the parameter information of the local interface is defined by the interface description language, so that the content of the local interface information can be clearer.
[0020] In an optional implementation manner, the method further includes:
[0021] When the local interface information in the GIT repository is updated, a change message corresponding to the updated local interface information is generated, and the change message is written into a message queue;
[0022] Based on the consumer mechanism, read the message queue;
[0023] The step of generating an interface code corresponding to the local interface information based on the local interface information includes:
[0024] In the case of reading a change message in the message queue, generating an interface code corresponding to the updated local interface information based on the updated local interface information;
[0025] Publishing the local interface information to the gateway includes:
[0026] The updated local interface information is published to the gateway.
[0027] In the disclosed embodiment, when the local interface information in the GIT repository is updated, multi-terminal interface code can be automatically generated and the updated code can be published to the gateway, so that the updated interface information can be provided to the interface users in a timely manner, which is conducive to improving the efficiency of interface research and development.
[0028] In an optional implementation manner, publishing the local interface information to the gateway includes:
[0029] Publish the local interface information directly to the gateway; or,
[0030] A query interface is provided so that the gateway can obtain the local interface information based on the query interface.
[0031] In the embodiments of the present disclosure, the local interface information is published to the gateway in the above two ways, so that the interface information publishing method has more selectivity.
[0032] The present disclosure provides an interface maintenance method, including:
[0033] Receiving local interface information sent by the server; the local interface information is used to generate a client interface code;
[0034] Receiving an interface access request sent by a client, wherein the interface access request is generated based on the client interface code;
[0035] Based on the parameter information of the local interface information, the parameter information of the interface access request is verified.
[0036] The disclosed embodiment verifies the parameter information of the interface access request based on the parameter information of the local interface information. This ensures the consistency between the parameter information of the interface access request submitted by the client and the local interface information after the interface goes online. This improves the security of the interface call after the interface goes online.
[0037] In an optional implementation manner, the method further includes:
[0038] When the parameter information of the interface access request is consistent with the parameter information of the local interface information, the interface access request is sent to the server.
[0039] In the disclosed embodiment, it is possible to avoid sending parameter information of an interface access request that does not meet the requirements to the server, thereby ensuring the security of the interface call.
[0040] In an optional implementation manner, after sending the interface access request to the server, the method further includes:
[0041] Receiving a return result generated by the server in response to the interface access request;
[0042] Based on the parameter information of the local interface information, verify the parameter information of the returned result;
[0043] When the parameter information of the returned result is consistent with the parameter information of the local interface information, the returned result is sent to the client.
[0044] In the disclosed embodiment, the gateway receives the return result generated by the server in response to the interface access request sent by the client, and verifies the return result, so as to ensure the consistency of the parameter information of the return result and the local interface information.
[0045] In an optional implementation manner, the method further includes:
[0046] When the parameter information of the interface access request is inconsistent with the parameter information of the local interface information, the parameter information inconsistent with the parameter information of the local interface information is removed to obtain a modified interface access request, and the modified interface access request is sent to the server.
[0047] In the disclosed embodiment, by removing parameter information inconsistent with the parameter information of the local interface information, the consistency of the parameter information of the interface access request and the parameter information of the local interface information can be ensured, thereby improving the security of the interface calling process.
[0048] In an optional implementation manner, the method further includes:
[0049] When the parameter information of the interface access request is inconsistent with the parameter information of the local interface information, generating first prompt information; and / or,
[0050] When the returned result is inconsistent with the parameter information of the local interface information, second prompt information is generated.
[0051] In the disclosed embodiment, prompt information is generated to facilitate prompting of management personnel.
[0052] The present disclosure also provides an interface maintenance device, the device comprising:
[0053] A generating module, configured to generate a multi-terminal interface code corresponding to the local interface information based on the local interface information; the multi-terminal interface code includes a client interface code, configured to implement a function corresponding to the local interface information on the client;
[0054] A publishing module is used to publish the local interface information to a gateway, so that the gateway verifies the parameter information of the interface access request sent by the client based on the parameter information of the local interface information, wherein the interface access request is generated based on the client interface code.
[0055] In an optional implementation, the multi-terminal interface code further includes a server interface code; the device further includes a code execution module, and the code execution module is used to:
[0056] In response to the interface access request sent by the gateway and based on parameter information of the interface access request, execute the server interface code corresponding to the local interface information corresponding to the interface access request, and generate a return result corresponding to the interface access request;
[0057] The publishing module is also used to:
[0058] The returned result is sent to a gateway, so that the gateway verifies the parameter information of the returned result based on the parameter information of the local interface information.
[0059] In an optional implementation manner, the interface access request carries target access service information; and the code execution module is specifically used to:
[0060] Determining local service interface information based on the target access service information;
[0061] Based on the local service interface information, the server interface code corresponding to the local interface information corresponding to the interface access request is executed.
[0062] In an optional implementation manner, the device further includes a definition module, wherein the definition module is configured to:
[0063] Based on the interface description language, the parameter information of the local interface is defined to generate the local interface information; the local interface information is stored in the GIT warehouse.
[0064] In an optional implementation manner, the definition module is further used to:
[0065] When the local interface information in the GIT repository is updated, a change message corresponding to the updated local interface information is generated, and the change message is written into a message queue;
[0066] Based on the consumer mechanism, read the message queue;
[0067] The generation module is specifically used for:
[0068] In the case of reading a change message in the message queue, generating an interface code corresponding to the updated local interface information based on the updated local interface information;
[0069] The publishing module is specifically used for:
[0070] The updated local interface information is published to the gateway.
[0071] In an optional implementation manner, the publishing module is specifically used to:
[0072] Publish the local interface information directly to the gateway; or,
[0073] A query interface is provided so that the gateway can obtain the local interface information based on the query interface.
[0074] The present disclosure also provides an interface maintenance device, the device comprising:
[0075] A receiving module, used for receiving local interface information sent by the server; the local interface information is used for generating a client interface code;
[0076] The receiving module is also used to receive an interface access request sent by a client, where the interface access request is generated based on the client interface code;
[0077] A verification module is used to verify the parameter information of the interface access request based on the parameter information of the local interface information.
[0078] In an optional implementation manner, the device further includes a sending module, wherein the sending module is configured to:
[0079] When the parameter information of the interface access request is consistent with the parameter information of the local interface information, the interface access request is sent to the server.
[0080] In an optional implementation manner, the receiving module is further used for:
[0081] Receiving a return result generated by the server in response to the interface access request;
[0082] The verification module is also used for:
[0083] Based on the parameter information of the local interface information, verify the parameter information of the returned result;
[0084] The sending module is also used for:
[0085] When the parameter information of the returned result is consistent with the parameter information of the local interface information, the returned result is sent to the client.
[0086] In an optional implementation manner, the device further includes a modification module, wherein the modification module is configured to:
[0087] In the case where the parameter information of the interface access request is inconsistent with the parameter information of the local interface information, removing the parameter information inconsistent with the parameter information of the local interface information to obtain a modified interface access request;
[0088] The sending module is also used for:
[0089] The modified interface access request is sent to the server.
[0090] In an optional implementation manner, the device further includes a prompt information generation module, and the prompt information generation module is used to:
[0091] When the parameter information of the interface access request is inconsistent with the parameter information of the local interface information, generating first prompt information; and / or,
[0092] When the returned result is inconsistent with the parameter information of the local interface information, second prompt information is generated.
[0093] An embodiment of the present disclosure also provides an electronic device, including: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and the above-mentioned interface maintenance method is executed when the machine-readable instructions are executed by the processor.
[0094] The embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the interface maintenance method is executed.
[0095] For a description of the effects of the above-mentioned interface maintenance device, electronic device, and computer-readable storage medium, please refer to the description of the above-mentioned interface maintenance method, which will not be repeated here.
[0096] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0097] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.
[0098] Figure 1 A schematic diagram of an interface development process provided by an embodiment of the present disclosure;
[0099] Figure 2 A flowchart of a first interface maintenance method provided by an embodiment of the present disclosure;
[0100] Figure 3 A flowchart of a second interface maintenance method provided by an embodiment of the present disclosure;
[0101] Figure 4 A flowchart of a method for executing a server-side interface code corresponding to local interface information provided by an embodiment of the present disclosure;
[0102] Figure 5 A flowchart of a third interface maintenance method provided by an embodiment of the present disclosure;
[0103] Figure 6 A flowchart of a fourth interface maintenance method provided by an embodiment of the present disclosure;
[0104] Figure 7 A flowchart of a fifth interface maintenance method provided by an embodiment of the present disclosure;
[0105] Figure 8 A flowchart of a sixth interface maintenance method provided by an embodiment of the present disclosure;
[0106] Fig. 9 A flowchart of a method for verifying a returned result provided by an embodiment of the present disclosure;
[0107] Fig.10 A schematic diagram of the structure of a first interface maintenance device provided by an embodiment of the present disclosure;
[0108] Fig.11A schematic diagram of the structure of a second interface maintenance device provided by an embodiment of the present disclosure;
[0109] Fig.12 A schematic diagram of the structure of a third interface maintenance device provided by an embodiment of the present disclosure;
[0110] Fig.13 A schematic diagram of the structure of a fourth interface maintenance device provided by an embodiment of the present disclosure;
[0111] Fig.14 A schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0112] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.
[0113] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0114] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.
[0115] See also Figure 1 , Figure 1 The following is a schematic diagram of an interface development process provided by an embodiment of the present disclosure. Figure 1As shown in , the interface development process can be implemented based on the application programming interface management platform (such as YAPI or swagger, etc.). The existing interface development process includes four stages: interface design, interface development, interface launch, and online operation and maintenance. Among them, interface design refers to defining the interface information on the server side and reviewing the defined interface information on the client side to ensure the design quality of the interface; interface development refers to handwriting the interface code of each end according to the defined interface information, which is used to implement the functional logic corresponding to the interface on each end to ensure the consistency of the interface design and implementation. However, the efficiency of handwriting interface code is low, and the consistency between code implementation and interface design requires code testing and joint debugging, which is prone to errors. Interface launch refers to maintaining the interface on the gateway and launching it on the server side and client side respectively. However, when updating the interface on the server side, it is necessary to manually and repeatedly publish the updated interface to the gateway to provide the client with the latest local interface information. This not only affects the real-time update of the client's interface information, but also reduces the efficiency of interface publishing.
[0116] In addition, after the interface goes online, that is, during the online operation and maintenance phase, there is still a lack of a mechanism to ensure that the interface information required to be accessed in the interface access request submitted by the client is consistent with the defined interface information. This will not only affect the normal communication between the server and the client, but also reduce the security of the interface calling process.
[0117] Based on the above research, an embodiment of the present disclosure provides an interface maintenance method, which includes: based on local interface information, generating a multi-terminal interface code corresponding to the local interface information; the multi-terminal interface code includes a client interface code, which is used to implement the function corresponding to the local interface information on the client; publishing the local interface information to a gateway, so that the gateway verifies the parameter information of the interface access request sent by the client based on the parameter information of the local interface information, wherein the interface access request is generated based on the client interface code.
[0118] In the disclosed embodiment, multi-terminal interface codes are generated based on local interface information to ensure the consistency of interface development codes between the terminals; and the local interface information is published to the gateway, so that the consistency of the interface information published on the gateway and the local interface information can be ensured, thereby improving the security of interface calls.
[0119] Combine the following Figure 2The interface maintenance method provided in the embodiment of the present disclosure is introduced in detail. The execution subject in the embodiment of the present disclosure is generally an electronic device with a certain computing capability, and the electronic device includes, for example: a terminal device or a server or other processing device. Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud storage, big data and artificial intelligence platforms. Other processing devices may be devices including processors and memories, which are not limited here. In some possible implementations, the interface maintenance method can be implemented by the processor calling computer-readable instructions stored in the memory. For the convenience of understanding and description, the following is a detailed introduction with the execution subject being a server.
[0120] See also Figure 2 , Figure 2 This is a flow chart of the first interface maintenance method provided by the embodiment of the present disclosure. Figure 2 As shown, the interface maintenance method provided in the embodiment of the present disclosure is applied to the server, including the following S101-S102:
[0121] S101, based on local interface information, generating a multi-terminal interface code corresponding to the local interface information; the multi-terminal interface code includes a client interface code, which is used to implement a function corresponding to the local interface information on the client.
[0122] Among them, the local interface information refers to the interface information defined on the server side. Specifically, the local interface information includes parameter information of the local interface, and the parameter information includes the interface method (GET, POST), path, request parameters, return parameters, serialization method (such as pb, or json) and other data information.
[0123] It can be understood that the server only provides interface information to the client. Since the underlying functional logic corresponding to the interface information cannot be executed only through the interface information, it is necessary to generate corresponding multi-terminal interface codes based on the local interface information, including server interface codes and client interface codes, so that the corresponding functions can be implemented on the server and client respectively. For example, the server can implement the underlying functional logic of the interface according to the server interface code, and the client can implement the underlying functional logic of the interface according to the client interface code, so that the user can submit an interface access request through the client, etc.
[0124] It should be noted that in the embodiment of the present disclosure, one piece of local interface information is used as an example for description. In other implementations, there may also be multiple pieces of local interface information, which is not limited here.
[0125] In some embodiments, when generating interface code corresponding to local interface information, multi-terminal interface code can be generated based on a code generation tool (scaffolding). Specifically, the scaffolding can be integrated into the API management platform, and multi-terminal interface code can be automatically generated based on the local interface information. In this way, not only can the consistency of the definition and implementation of the interface information between the server and the client be guaranteed, the reliability is high, but also the R&D efficiency can be improved.
[0126] In the disclosed embodiment, the local interface information is interface information described by an interface description language (IDL). It can be understood that IDL is a language used to describe interfaces, which is independent of programming languages and can describe interfaces in a neutral way so that objects running on different platforms and programs written in different languages can communicate with each other. Since IDL has clear semantics and a simple structure, it can also be used to describe other data types.
[0127] In addition, using IDL to define the parameter information of the local interface has the following advantages:
[0128] (1) Strong ability to describe the public model. For example, when two interfaces have some identical description information, the same part can be defined as a public model. This can avoid repeated definitions and improve the reusability of the public model. In addition, when modifying the interface information, it only needs to be modified once, which helps save time and cost in R&D.
[0129] (2) The maintenance methods for HTTP and RPC are relatively unified. HTTP (network transmission protocol) and RPC (remote procedure call) refer to the two ways for the client to call the server interface. When the client calls IDL, both methods can be supported at the same time.
[0130] (3) It can be connected with the functions released by the code generation tool and the gateway, so that the interface external update and interface function implementation can be completed quickly.
[0131] S102, publishing the local interface information to a gateway, so that the gateway verifies the parameter information of the interface access request sent by the client based on the parameter information of the local interface information, wherein the interface access request is generated based on the client interface code.
[0132] Among them, gateway refers to a service with forwarding function.
[0133] Specifically, during the interface publishing stage, the local interface information can be published to the gateway. Since the gateway has a forwarding function, when the gateway receives an interface access request, it can accurately forward the client's interface access request to the server to determine the service corresponding to the interface access request.
[0134] In some implementations, for step S102, when publishing the local interface information to the gateway, the local interface information may be directly published to the gateway; or a query interface may be provided so that the gateway can obtain the local interface information by calling the query interface. In this way, the interface information publishing method may have more options.
[0135] In the disclosed embodiment, multi-terminal interface codes are generated based on local interface information to ensure the consistency of interface development codes between the terminals; and the local interface information is published to the gateway, so that the consistency of the interface information published on the gateway and the local interface information can be ensured, thereby improving the security of interface calls.
[0136] It can be understood that in order to ensure the consistency between the parameter information of the interface access request and the parameter information of the local interface information, it is necessary to perform a consistency check on the parameter information of the interface access request.
[0137] See also Figure 3 , Figure 3 This is a flow chart of a second interface maintenance method provided by an embodiment of the present disclosure. Figure 2 The interface maintenance method shown in is different in that the multi-terminal interface code also includes a server interface code; the interface maintenance method also includes the following S103-S104:
[0138] S103, in response to the interface access request sent by the gateway and based on the parameter information of the interface access request, execute the server interface code corresponding to the local interface information corresponding to the interface access request, and generate a return result corresponding to the interface access request.
[0139] It can be understood that if the gateway detects that the parameter information of the interface access request sent by the client is consistent with the parameter information of the local interface information, the gateway will forward the interface access request to the server, and the server will execute the corresponding server logic according to the interface access request and generate a return result.
[0140] S104: Send the returned result to a gateway, so that the gateway verifies the parameter information of the returned result based on the parameter information of the local interface information.
[0141] The parameter information of the returned result also includes the interface method (GET, POST), path, request parameters, return parameters, serialization method (such as pb, or json) and other data information.
[0142] During the interface maintenance process, in addition to the consistency check of the interface access request sent by the client, the return result generated by the server in response to the interface access request needs to be checked. Therefore, the server needs to send the return result to the gateway so that the gateway can check the parameter information of the return result. In this way, the consistency of the return result generated by the server in response to the interface access request and the parameter information of the local interface information can be ensured.
[0143] In some implementations, the interface access request carries target access service information; for the above step S103, when executing the server interface code corresponding to the local interface information corresponding to the interface access request based on the parameter information of the interface access request, such as Figure 4 As shown, it includes the following S1031~S1032:
[0144] S1031: Determine local service interface information based on the target access service information.
[0145] S1032: Based on the local service interface information, execute the server interface code corresponding to the local interface information corresponding to the interface access request.
[0146] It can be understood that when the gateway forwards the interface access request submitted by the client to the server, it will first determine the service of the server corresponding to the interface access request based on the target access service information carried in the interface access request, and then determine the local interface information based on the service. In this way, the scope of the local interface information can be narrowed, thereby improving the efficiency of determining the local interface information.
[0147] The target access service information refers to the information of the server service that the user needs to access and submitted by the client.
[0148] Exemplarily, the interface access request submitted by the client may be an interface access request for calling the interface for establishing a live broadcast room in the live broadcast service of the server. When the server receives the interface access request, it will first determine the live broadcast service, and determine the interface for establishing the live broadcast room based on the live broadcast service. In this way, the client can call the interface to implement the interface function corresponding to the interface access request.
[0149] See also Figure 5 , Figure 5 A flowchart of a third interface maintenance method provided by an embodiment of the present disclosure, and Figure 2The interface maintenance method in is different from that in Figure 5 As shown, before step S101, it also includes S100:
[0150] S100, based on an interface description language, define parameter information of the local interface and generate the local interface information; the local interface information is stored in a GIT repository.
[0151] Among them, GIT is an open source distributed version control system that can efficiently handle project version management. GIT consists of two parts: a remote warehouse system and a local development tool, and provides a local command line tool. The GIT command line tool can be used to efficiently interact with the GIT remote server. For example, developers can use GIT commands to push local interface information developed locally to the remote warehouse, and other developers can pull the latest local interface information pushed from the remote warehouse.
[0152] See also Figure 6 , Figure 6 This is a flowchart of a fourth interface maintenance method provided by an embodiment of the present disclosure, such as Figure 6 As shown in , the method includes the following S201 to S205:
[0153] S201, based on the interface description language, define the parameter information of the local interface and generate the local interface information; the local interface information is stored in the GIT warehouse.
[0154] S202: When the local interface information in the GIT repository is updated, a change message corresponding to the updated local interface information is generated, and the change message is written into a message queue.
[0155] The message queue refers to a container for storing messages during the transmission of the messages. In the embodiment of the present disclosure, the message queue can be managed by a distributed log system (Kafka).
[0156] S203, based on the consumer mechanism, read the message queue.
[0157] S204: When a change message is read from the message queue, an interface code corresponding to the updated local interface information is generated based on the updated local interface information.
[0158] In this embodiment, in order to realize automatic update of the interface code, when the change message of the local interface information is read, the code generation tool (scaffold) can be automatically triggered to automatically generate code, thereby improving the efficiency and accuracy of code generation.
[0159] S205: Publish the updated local interface information to the gateway.
[0160] It is understandable that when the local interface information is updated, the updated local interface information also needs to be published to the gateway to ensure that the updated local interface information can be put online in time, thereby ensuring the consistency of the local interface information published and updated by the gateway.
[0161] See also Figure 7 , Figure 7 The flowchart of the fifth interface maintenance method provided by the embodiment of the present disclosure is applied to the gateway, such as Figure 7 As shown in , the method includes the following S701-S703:
[0162] S701, receiving local interface information sent by a server; the local interface information is used to generate a client interface code.
[0163] It can be understood that in order for the gateway to verify the parameter information of the interface access request, the gateway needs to receive the local interface information sent by the server to verify the parameter information of the interface access request sent by the client.
[0164] S702: Receive an interface access request sent by a client, where the interface access request is generated based on the client interface code.
[0165] It can be understood that the interface access request is generated based on the interface code of the client, and when the client submits the interface access request to the server, it first needs to send the interface access request to the gateway.
[0166] S703: Verify the parameter information of the interface access request based on the parameter information of the local interface information.
[0167] Specifically, after receiving the interface access request, the gateway can determine the local interface information according to the parameter information of the interface access request, and compare the local interface information with the parameter information of the interface access request, thereby completing the verification of the parameter information of the interface access request.
[0168] See also Figure 8 , Figure 8 This is a flow chart of a sixth interface maintenance method provided by an embodiment of the present disclosure, such as Figure 8 As shown in , the interface maintenance method provided in this embodiment includes the following S801 to S805:
[0169] S801, receiving local interface information sent by a server; the local interface information is used to generate a client interface code.
[0170] S802: Receive an interface access request sent by a client, where the interface access request is generated based on the client interface code.
[0171] The specific description of steps S801 to S802 is similar to the specific description of steps S701 to S702 in the aforementioned embodiment, and will not be repeated here.
[0172] S803, based on the parameter information of the local interface information, determine whether the parameter information of the interface access request is consistent with the parameter information of the local interface information, if so, execute step S804, if not, execute step S805.
[0173] S804: Send the interface access request to the server.
[0174] It can be understood that the interface access request submitted by the client needs to be submitted to the server for processing. Therefore, when the gateway verifies that the parameter information of the interface access request is consistent with the parameter information of the local interface information, the interface access request is submitted to the server. In this way, the security of the interface access request can be ensured.
[0175] S805, removing parameter information inconsistent with the local interface information, obtaining a modified interface access request, and sending the modified interface access request to the server.
[0176] It can be understood that if the gateway detects that the parameter information of the interface access request sent by the client is inconsistent with the parameter information of the local interface information, the parameter information inconsistent with the local interface information will be removed to obtain a modified interface access request, and the modified interface access request can be sent to the server. In other embodiments, if the gateway detects that the parameter information of the interface access request sent by the client is inconsistent with the parameter information of the local interface, the interface access request can be intercepted and a prompt message can be generated, thereby ensuring the security of the interface access request sent by the client.
[0177] See also Fig. 9 , Fig. 9 A flowchart of a verification method for returning a result provided by an embodiment of the present disclosure is shown in FIG. Fig. 9 As shown in , the interface maintenance method provided in this embodiment includes the following S901 to S904:
[0178] S901, receiving a return result generated by the server in response to the interface access request.
[0179] For the specific description information of the returned result, please refer to the description content of step S104, which will not be repeated here.
[0180] S902, based on the parameter information of the local interface information, determine whether the parameter information of the returned result is consistent with the parameter information of the local interface information, if so, execute step S903, if not, execute step S904.
[0181] S903: Send the returned result to the client.
[0182] It can be understood that the interface maintenance process also includes the verification of the return results sent by the server to the gateway. Therefore, the gateway needs to receive the return results sent by the server and verify the parameter information of the return results based on the parameter information of the local interface information. If the parameter information of the local interface information is consistent with the parameter information of the return result, the return result will be sent to the client to complete the entire process of the interface access request.
[0183] S904, removing parameter information inconsistent with the local interface information, obtaining a modified return result, and sending the modified return result to the client.
[0184] It can be understood that the modified return result meets the requirements, and the modified return result can be sent to the server to complete the entire process of the interface call. In other embodiments, if the parameter information of the return result is inconsistent with the parameter information of the local interface information, the return result can also be intercepted, so that the server can avoid sending some data that does not meet the requirements (for example, sensitive data) to the client, thereby ensuring the security of the interface call.
[0185] Exemplarily, the inconsistent parameter information may be some sensitive parameter information. Specifically, when defining the parameter information of the interface, in order to protect the user's information and comply with relevant regulations, the sensitive parameter information will not be defined as the parameter information of the local interface information. However, the parameter information of the interface access request submitted by the client may carry sensitive parameter information. In this case, the sensitive parameter information needs to be removed. Exemplarily, the sensitive parameter information may be parameter information such as the user's name or the user's mobile phone number, which is not limited here.
[0186] In some implementations, when the parameter information of the interface access request is inconsistent with the parameter information of the local interface information, first prompt information may be generated to prompt the administrator.
[0187] In other implementations, when the returned result is inconsistent with the parameter information of the local interface information, a second prompt information may be generated to prompt the administrator.
[0188] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0189] Based on the same inventive concept, an interface maintenance device corresponding to the interface maintenance method is also provided in the embodiment of the present disclosure. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the above-mentioned interface maintenance method in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0190] See also Fig.10 , is a schematic diagram of the structure of the first interface maintenance device provided by the embodiment of the present disclosure, the device comprises: a generation module 1010 and a publishing module 1020; wherein,
[0191] A generating module 1010, configured to generate a multi-terminal interface code corresponding to the local interface information based on the local interface information; the multi-terminal interface code includes a client interface code, configured to implement a function corresponding to the local interface information on the client;
[0192] The publishing module 1020 is used to publish the local interface information to the gateway, so that the gateway verifies the parameter information of the interface access request sent by the client based on the parameter information of the local interface information, wherein the interface access request is generated based on the client interface code.
[0193] See also Fig.11 , Fig.11 A schematic diagram of the structure of a second interface maintenance device provided in an embodiment of the present disclosure, Fig.10 The interface maintenance device shown in FIG. 1 is different in that the multi-terminal interface code also includes a server interface code; the device also includes a code execution module 1030, and the code execution module 1030 is used to:
[0194] In response to the interface access request sent by the gateway and based on parameter information of the interface access request, execute the server interface code corresponding to the local interface information corresponding to the interface access request, and generate a return result corresponding to the interface access request;
[0195] The publishing module 1020 is also used for:
[0196] The returned result is sent to a gateway, so that the gateway verifies the parameter information of the returned result based on the parameter information of the local interface information.
[0197] In an optional implementation manner, the interface access request carries target access service information; and the code execution module 1030 is specifically configured to:
[0198] Determining local service interface information based on the target access service information;
[0199] Based on the local service interface information, the server interface code corresponding to the local interface information corresponding to the interface access request is executed.
[0200] In an optional implementation manner, the device further includes: a definition module 1040, wherein the definition module 1040 is configured to:
[0201] Based on the interface description language, the parameter information of the local interface is defined to generate the local interface information; the local interface information is stored in the GIT warehouse.
[0202] In an optional implementation manner, the definition module 1040 is further configured to:
[0203] When the local interface information in the GIT repository is updated, a change message corresponding to the updated local interface information is generated, and the change message is written into a message queue;
[0204] Based on the consumer mechanism, read the message queue;
[0205] The generating module 1010 is specifically used for:
[0206] In the case of reading a change message in the message queue, generating an interface code corresponding to the updated local interface information based on the updated local interface information;
[0207] The publishing module 1020 is specifically used for:
[0208] The updated local interface information is published to the gateway.
[0209] In an optional implementation manner, the publishing module 1020 is specifically configured to:
[0210] Publish the local interface information directly to the gateway; or,
[0211] A query interface is provided so that the gateway can obtain the local interface information based on the query interface.
[0212] See also Fig.12 , Fig.12 A schematic diagram of the structure of a third interface maintenance device provided in an embodiment of the present disclosure, such as Fig.12 As shown in , the device includes a receiving module 1110 and a checking module 1120; wherein:
[0213] The receiving module 1110 is used to receive the local interface information sent by the server; the local interface information is used to generate the client interface code;
[0214] The receiving module 1110 is further configured to receive an interface access request sent by a client, wherein the interface access request is generated based on the client interface code;
[0215] The verification module 1120 is used to verify the parameter information of the interface access request based on the parameter information of the local interface information.
[0216] See also Fig.13 , Fig.13 A schematic diagram of the structure of a fourth interface maintenance device provided in an embodiment of the present disclosure, such as Fig.13 As shown in , the device further includes a sending module 1130, and the sending module 1130 is used to:
[0217] When the parameter information of the interface access request is consistent with the parameter information of the local interface information, the interface access request is sent to the server.
[0218] In an optional implementation manner, the receiving module 1110 is further configured to:
[0219] Receiving a return result generated by the server in response to the interface access request;
[0220] The verification module 1120 is also used for:
[0221] Based on the parameter information of the local interface information, verify the parameter information of the returned result;
[0222] The sending module 1130 is also used for:
[0223] When the parameter information of the returned result is consistent with the parameter information of the local interface information, the returned result is sent to the client.
[0224] In an optional implementation manner, the device further includes a modification module 1140, and the modification module 1140 is configured to:
[0225] In the case where the parameter information of the interface access request is inconsistent with the parameter information of the local interface information, removing the parameter information inconsistent with the parameter information of the local interface information to obtain a modified interface access request;
[0226] The sending module 1130 is also used for:
[0227] The modified interface access request is sent to the server.
[0228] In an optional implementation, the device further includes a prompt information generating module 1150, and the prompt information generating module 1150 is used to:
[0229] When the parameter information of the interface access request is inconsistent with the parameter information of the local interface information, generating first prompt information; and / or,
[0230] When the returned result is inconsistent with the parameter information of the local interface information, second prompt information is generated.
[0231] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0232] Based on the same technical concept, the embodiment of the present disclosure also provides an electronic device. Fig.14 1 is a schematic diagram of the structure of an electronic device 1500 provided in an embodiment of the present disclosure, including a processor 1501, a memory 1502, and a bus 1503. The memory 1502 is used to store execution instructions, including a memory 15021 and an external memory 15022; the memory 15021 is also called an internal memory, which is used to temporarily store the operation data in the processor 1501 and the data exchanged with the external memory 15022 such as a hard disk. The processor 1501 exchanges data with the external memory 15022 through the memory 15021.
[0233] In the embodiment of the present application, the memory 1502 is specifically used to store the application code for executing the solution of the present application, and the execution is controlled by the processor 1501. That is, when the electronic device 1500 is running, the processor 1501 communicates with the memory 1502 through the bus 1503, so that the processor 1501 executes the application code stored in the memory 1502, and then executes the method in any of the aforementioned embodiments.
[0234] Processor 1501 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present disclosure may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0235] Among them, the memory 1502 can be, but is not limited to, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), programmable read-only memory (Programmable Read-Only Memory, PROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable read-only memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.
[0236] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 800. In other embodiments of the present application, the electronic device 800 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0237] The embodiment of the present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the interface maintenance method described in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.
[0238] The present disclosure also provides a computer program product that carries a program code. The program code includes instructions that can be used to execute the steps of the interface maintenance method described in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.
[0239] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0240] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and terminal described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, terminal and method can be implemented in other ways. The terminal embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, or the indirect coupling or communication connection of the units, which can be electrical, mechanical or other forms.
[0241] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0242] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0243] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling an electronic device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0244] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. An interface maintenance method, characterized in that: Applied to the server, including: Based on the local interface information, a multi-terminal interface code corresponding to the local interface information is generated; the multi-terminal interface code includes a client interface code and a server interface code, and the client interface code is used to implement a function corresponding to the local interface information on the client; Publishing the local interface information to a gateway, so that the gateway verifies the parameter information of the interface access request sent by the client based on the parameter information of the local interface information, wherein the interface access request is generated based on the client interface code; Wherein, after publishing the local interface information to the gateway, the method further includes: In response to the interface access request sent by the gateway and based on parameter information of the interface access request, execute the server interface code corresponding to the local interface information corresponding to the interface access request, and generate a return result corresponding to the interface access request; The returned result is sent to a gateway, so that the gateway verifies the parameter information of the returned result based on the parameter information of the local interface information.
2. The method according to claim 1, characterized in that The interface access request carries target access service information; and the execution of the server interface code corresponding to the local interface information corresponding to the interface access request based on the parameter information of the interface access request includes: Determining local service interface information based on the target access service information; Based on the local service interface information, the server interface code corresponding to the local interface information corresponding to the interface access request is executed.
3. The method according to claim 1, characterized in that Before generating a multi-terminal interface code corresponding to the local interface information based on the local interface information, the method further includes: Based on the interface description language, the parameter information of the local interface is defined to generate the local interface information; the local interface information is stored in the GIT warehouse.
4. The method according to claim 3, characterized in that: The method further comprises: When the local interface information in the GIT repository is updated, a change message corresponding to the updated local interface information is generated, and the change message is written into a message queue; Based on the consumer mechanism, read the message queue; The step of generating an interface code corresponding to the local interface information based on the local interface information includes: In the case of reading a change message in the message queue, generating an interface code corresponding to the updated local interface information based on the updated local interface information; Publishing the local interface information to the gateway includes: The updated local interface information is published to the gateway.
5. The method according to claim 1, characterized in that Publishing the local interface information to the gateway includes: Publish the local interface information directly to the gateway; or, A query interface is provided so that the gateway can obtain the local interface information based on the query interface.
6. An interface maintenance method, characterized in that: Applied to gateways, including: Receive local interface information sent by the server; the local interface information is used to generate a client interface code and a server interface code; Receiving an interface access request sent by a client, wherein the interface access request is generated based on the client interface code; Based on the parameter information of the local interface information, verify the parameter information of the interface access request; When the parameter information of the interface access request is consistent with the parameter information of the local interface information, sending the interface access request to the server; receiving a return result generated by the server executing the server interface code corresponding to the local interface information corresponding to the interface access request in response to the interface access request; Based on the parameter information of the local interface information, the parameter information of the returned result is verified.
7. The method according to claim 6, characterized in that The method further comprises: When the parameter information of the returned result is consistent with the parameter information of the local interface information, the returned result is sent to the client.
8. The method according to claim 6, characterized in that The method further comprises: When the parameter information of the interface access request is inconsistent with the parameter information of the local interface information, the parameter information inconsistent with the parameter information of the local interface information is removed to obtain a modified interface access request, and the modified interface access request is sent to the server.
9. The method according to claim 7, characterized in that: The method further comprises: When the parameter information of the interface access request is inconsistent with the parameter information of the local interface information, generating first prompt information; and / or, When the returned result is inconsistent with the parameter information of the local interface information, second prompt information is generated.
10. An interface maintenance device, characterized in that: include: A generating module, configured to generate a multi-terminal interface code corresponding to the local interface information based on the local interface information; The multi-terminal interface code includes a client interface code and a server interface code, and the client interface code is used to implement a function corresponding to the local interface information on the client; A publishing module, used for publishing the local interface information to a gateway, so that the gateway verifies the parameter information of the interface access request sent by the client based on the parameter information of the local interface information, wherein the interface access request is generated based on the client interface code; A code execution module, configured to respond to the interface access request sent by the gateway and, based on parameter information of the interface access request, execute a server-side interface code corresponding to the local interface information corresponding to the interface access request, and generate a return result corresponding to the interface access request; The publishing module is further used to send the returned result to a gateway, so that the gateway verifies the parameter information of the returned result based on the parameter information of the local interface information.
11. An interface maintenance device, characterized in that: include: A receiving module, used for receiving local interface information sent by the server; The local interface information is used to generate a client interface code and a server interface code; The receiving module is also used to receive an interface access request sent by a client, where the interface access request is generated based on the client interface code; A verification module, used for verifying the parameter information of the interface access request based on the parameter information of the local interface information; A sending module, configured to send the interface access request to the server when the parameter information of the interface access request is consistent with the parameter information of the local interface information; The receiving module is further used to receive a return result generated by the server executing the server interface code corresponding to the local interface information corresponding to the interface access request in response to the interface access request; The verification module is further used to verify the parameter information of the returned result based on the parameter information of the local interface information.
12. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the interface maintenance method as described in any one of claims 1 to 9 is executed.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the interface maintenance method according to any one of claims 1 to 9 is executed.
