A request processing method and device, electronic equipment and storage medium
By receiving and processing different types of call parameters and responding to client requests based on logic code snippets, the problem of low interface development efficiency is solved, and more efficient interface management and response are achieved.
Patent Information
- Application Number
- CN202110777065.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-09
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2041-07-09
AI Technical Summary
Existing technologies suffer from low interface development efficiency, requiring the development of different interfaces based on different request content, which leads to complex and inefficient testing and deployment.
By receiving client requests to call a specified interface, determining the type of the call parameters, and returning the corresponding call result based on the logic code snippet of that type, the system supports at least two different types of call parameters, reducing the overhead of interface development.
It improves the efficiency of interface development, reduces the complexity of interface development and testing workload, and enhances the flexibility and response speed of interfaces.
Smart Images

Figure CN113448589B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of software development technology, and in particular to a request processing method, apparatus, electronic device, and storage medium. Background Technology
[0002] The backend server and the frontend browser transmit data through interfaces. Different requests from the browser require different interfaces from the server. The server needs to develop different interfaces for each request, and each new interface requires redefining the interface parameters and path. Furthermore, after development, the interface needs to be tested and integrated in multiple environments. In other words, interface development efficiency is relatively low in this technology. Summary of the Invention
[0003] In view of this, the main objective of the embodiments of this application is to provide a request processing method, apparatus, electronic device and storage medium to solve the problem of low interface development efficiency in related technologies.
[0004] To achieve the above objectives, the technical solution of this application embodiment is implemented as follows:
[0005] This application provides a request processing method, the method including:
[0006] Receive client requests to set up an interface; the set up interface supports at least two different types of call parameters;
[0007] Determine the type of the call parameters in the call request;
[0008] Based on the logic code fragment corresponding to the type of the calling parameters, the corresponding calling result is returned to the client.
[0009] In the above scheme, returning the corresponding call result to the client based on the logic code fragment corresponding to the type of the call parameter includes:
[0010] By calling the class corresponding to the type of the calling parameter, the logic code segment corresponding to the type of the calling parameter is executed to obtain the calling result;
[0011] The call result is returned to the client; wherein,
[0012] The class corresponding to the type of the calling parameter is compiled from the logic code fragment corresponding to the type of the calling parameter.
[0013] In the above scheme, the step of executing the logical code segment corresponding to the type of the calling parameter by calling the class corresponding to the type of the calling parameter includes:
[0014] Search among all classes that implement the first interface to find if there exists a class corresponding to the type of the calling parameter, and obtain the query results;
[0015] If the query result indicates the existence of a class corresponding to the type of the calling parameter, the logic code segment corresponding to the type of the calling parameter is executed by calling the class corresponding to the type of the calling parameter.
[0016] In the above scheme, before receiving the client's request to call the designated interface, the method further includes:
[0017] Create the first interface;
[0018] Create at least one method in the first interface;
[0019] In each of the at least one methods, a logic code fragment corresponding to the type of the calling parameter is written.
[0020] The method in the above scheme further includes:
[0021] At set intervals, scan the update time of the logic code segment corresponding to the type of the called parameter;
[0022] If the update time obtained by the scan is later than the update time obtained by the previous scan, obtain the logic code fragment corresponding to the type of the call parameter corresponding to the update time obtained by the scan;
[0023] Based on the logic code fragment corresponding to the type of the obtained call parameter, update the class corresponding to the type of the call parameter.
[0024] In the above scheme, before scanning the update time of the logic code segment corresponding to the type of the calling parameter at set intervals, the method further includes:
[0025] Save the types of the call parameters and their corresponding logic code snippets;
[0026] Save the type of the call parameters and their corresponding class.
[0027] The method in the above scheme further includes:
[0028] If the query result indicates that there is no class corresponding to the type of the calling parameter, an exception handling result is returned to the client.
[0029] This application embodiment also provides a request processing apparatus, the apparatus comprising:
[0030] A receiving unit is used to receive a client's call request for a specified interface; the specified interface supports at least two different types of call parameters;
[0031] A determining unit is used to determine the type of the calling parameters in the calling request;
[0032] The return unit is used to return the corresponding call result to the client based on the logic code fragment corresponding to the type of the call parameter.
[0033] This application also provides an electronic device, including: a processor and a memory for storing a computer program capable of running on the processor, wherein,
[0034] When the processor is used to run the computer program, it performs the steps of any of the above methods.
[0035] This application also provides a storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the above methods.
[0036] In this embodiment, by receiving a client's call request to a designated interface, the type of the call parameters in the call request is determined. The designated interface supports at least two different types of call parameters. Then, based on the logic code fragment corresponding to the type of call parameter, the corresponding call result is returned to the client. In this way, the server can respond to call requests using different types of call parameters through a single designated interface, eliminating the need to develop different interfaces for different call requests, thus saving the overhead of interface development and improving the efficiency of interface development. Attached Figure Description
[0037] Figure 1 A schematic diagram illustrating the implementation flow of the request processing method provided in this application embodiment;
[0038] Figure 2 The request processing method provided for the application embodiments of this application;
[0039] Figure 3 Another request processing method provided for application embodiments of this application
[0040] Figure 4 A schematic diagram of a request processing apparatus provided in an embodiment of this application;
[0041] Figure 5 This is a schematic diagram of the hardware structure of the electronic device according to an embodiment of this application. Detailed Implementation
[0042] Backend servers and frontend browsers transmit data via interfaces. Different browser requests require different interfaces from the server. For example, a browser requesting a user's avatar and a user identifier will require different interfaces. This means the server needs to develop different interfaces for different request content. Each new interface requires redefining interface parameters and paths, and after development, it needs to be tested and integrated in multiple environments (testing, pre-release, and production). Furthermore, the backend server needs to be redeployed to implement the new interface logic. Taking Java as an example, even a small logic change requires redeployment. Therefore, interface development efficiency is relatively low in this technology.
[0043] Based on this, embodiments of this application provide a request processing method, apparatus, electronic device, and storage medium. By receiving a client's call request to a designated interface, the method determines the type of the call parameters in the call request. The designated interface supports at least two different types of call parameters. Then, based on the logic code fragment corresponding to the type of call parameter, the method returns the corresponding call result to the client. In this way, the server can respond to call requests using different types of call parameters through a single designated interface, eliminating the need to develop different interfaces for different call requests, thereby saving the overhead of interface development and improving the efficiency of interface development.
[0044] The present application will now be described in further detail with reference to the accompanying drawings and embodiments.
[0045] Figure 1 This is a schematic diagram illustrating the implementation flow of the request processing method provided in an embodiment of this application. For example... Figure 1 As shown, the method includes:
[0046] Step 101: Receive a client's request to call the setting interface; the setting interface supports at least two different types of call parameters.
[0047] Here, the interface is configured to support at least two different types of call parameters, with each type of parameter corresponding to a different type of call request. In other words, in this embodiment, different types of call requests can invoke the same interface. The server receives the client's call request for the interface. The interface path for the interface is predefined, and the client invokes the interface based on this path.
[0048] In practical applications, the interface can be set to either Hypertext Transfer Protocol (HTTP) or Remote Procedure Call (RPC). The server receives client requests to call either the HTTP or RPC interface.
[0049] Step 102: Determine the type of the call parameters in the call request.
[0050] Here, the server parses the call request to access the interface path. Specifically, after receiving the client's call request for the set interface, the server parses the received call request to obtain the type of the call parameters in the call request.
[0051] When setting up the interface, the server also specifies that the data structure of the input parameters for the call request to the interface is a Map structure. A Map is a collection of key-value pairs, which is an associative array that associates the value of an element with a specific key. In this embodiment, the Map of input parameters for the call request includes a parameter `type`, which represents the type of call parameter in the call request. The Map also includes a parameter `data`, which represents the data that the call request to the interface aims to retrieve.
[0052] For example, the server defines the interface path of the interface as http: / / domain / api / union / apply, the interface type as POST, and the interface request as Application / json. It receives the client's call request to the interface, parses the call request, and finds that the type of the input parameters of the call request is getUserInfo, which indicates that the type of the call parameter in the call request is to obtain user information, and the data is UserID, which indicates that the data to be obtained by the call request is user identification information.
[0053] Step 103: Based on the logic code fragment corresponding to the type of the calling parameter, return the corresponding calling result to the client.
[0054] Here, after parsing the type of the call parameters, the server returns the corresponding call result to the client based on the logic code fragment corresponding to the type of the call parameters. The logic code fragment is used to process the call parameters of the corresponding type.
[0055] For example, after parsing the call parameter as getUserInfo, the server returns the corresponding call result to the client based on the logic code fragment corresponding to the getUserInfo type: "name:zhangsan", "sex:male", "age:18", which means that the data requested by the call request to obtain user information is the user's name, gender, and age.
[0056] In practical applications, in addition to returning the corresponding call result to the client, the server will also return the status code information and timestamp information of this call request. For example, returning "code: ok", "success: true", and "timestamp: 2021.04.15 23:23:23" to the client indicates that the call request was successful, and the timestamp information indicates the time when the client initiated the call request to the specified interface.
[0057] In one embodiment, returning the corresponding call result to the client based on the logic code fragment corresponding to the type of the call parameter includes:
[0058] By calling the class corresponding to the type of the calling parameter, the logic code segment corresponding to the type of the calling parameter is executed to obtain the calling result;
[0059] The call result is returned to the client; wherein,
[0060] The class corresponding to the type of the calling parameter is compiled from the logic code fragment corresponding to the type of the calling parameter.
[0061] Here, after determining the type of the call parameter, the server calls the class corresponding to the type of the call parameter, determines the logic code segment corresponding to the type of the call parameter based on the class, executes the logic code segment corresponding to the type of the call parameter, obtains the call result, and returns the call result to the client.
[0062] The class corresponding to the type of the call parameter is obtained by compiling the logic code fragment corresponding to the type of the call parameter. In practical applications, the server can compile the logic code fragment using JavaStringCompiler or a third-party Groovy compiler. Groovy is a convenient development language based on the Java Virtual Machine (JVM). It combines many powerful features of Python, Ruby, and Smalltalk. Groovy code can be well integrated with Java code and can be used to flexibly extend existing code.
[0063] It should be noted that, for ease of invocation and to improve the efficiency of responding to invocation requests, the logic code snippets need to be compiled into classes of the corresponding types. After determining the type of the invocation parameter, the logic code snippet corresponding to the type of the invocation parameter is determined by the class corresponding to that type of invocation parameter.
[0064] In this embodiment of the application, by calling the class corresponding to the type of the calling parameter and executing the logic code segment corresponding to the type of the calling parameter, the response speed of the call request for the type of the calling parameter can be improved, and the response accuracy of the call request can also be improved.
[0065] In one embodiment, the step of executing the logic code fragment corresponding to the type of the calling parameter by calling the class corresponding to the type of the calling parameter includes:
[0066] Search among all classes that implement the first interface to find if there exists a class corresponding to the type of the calling parameter, and obtain the query results;
[0067] If the query result indicates the existence of a class corresponding to the type of the calling parameter, the logic code segment corresponding to the type of the calling parameter is executed by calling the class corresponding to the type of the calling parameter.
[0068] Here, the server first checks among all classes implementing the first interface to see if a class corresponding to the type of the called parameter exists. The first interface stores the logic code snippets corresponding to the types of various called parameters. Each class resulting from compiling the logic code snippet corresponding to a type of called parameter can implement the first interface. In other words, by checking all classes implementing the first interface, it can be determined which logic code snippets corresponding to the types of called parameters are stored in the first interface.
[0069] If a class corresponding to the type of the call parameter is found among all classes implementing the first interface, it indicates that the first interface stores the logical code fragment corresponding to the type of the call parameter. Therefore, the class corresponding to the type of the call parameter is called, and the logical code fragment corresponding to the type of the call parameter is executed.
[0070] By querying all classes implementing the first interface to see if a class corresponding to the type of the calling parameter exists, and if so, calling the class corresponding to the type of the calling parameter to execute the logic code segment corresponding to the type of the calling parameter, the response speed to the calling request corresponding to the type of the calling parameter can be improved.
[0071] In one embodiment, the method further includes:
[0072] If the query result indicates that there is no class corresponding to the type of the calling parameter, an exception handling result is returned to the client.
[0073] Here, if the server finds no class corresponding to the type of the calling parameter among all classes implementing the first interface, it indicates that there is no logical code segment in the server that can handle the type of the calling parameter, and therefore it cannot respond to the calling parameter. So the server returns an exception handling result to the client.
[0074] By returning an exception handling result to the client when the type of the called parameter does not exist, timely feedback can be provided to the client.
[0075] In one embodiment, before receiving the client's request to call the designated interface, the method further includes:
[0076] Create the first interface;
[0077] Create at least one method in the first interface;
[0078] In each of the at least one methods, a logic code fragment corresponding to the type of the calling parameter is written.
[0079] Here, before receiving a client's request to call the designated interface, a first interface is created. Within this first interface, at least one method is created, each describing a function of the first interface. In each method, a logic code snippet corresponding to the type of a call parameter is written.
[0080] For example, taking Java as an example, first, a first interface `logic` is created. Within this first interface `logic`, a `handle` method is defined, specifying that the input parameter data structure for the `handle` method is a Map, and the output parameter data structure is also a Map. A logic code snippet corresponding to the type of the called parameter is then written into the `handle` method.
[0081] It should be noted that the first interface and the setting interface are not the same interface. The setting interface is the specific implementation interface for data interaction; specifically, the client can obtain specific response data based on the call request to the setting interface. The first interface, on the other hand, is an abstract type in a programming language, a collection of abstract methods. In actual programming, the first interface is declared using the `interface` keyword.
[0082] By pre-writing logical code snippets corresponding to the types of the call parameters, a quick response can be made upon receiving a call request from a client, based on the logical code snippets corresponding to the types of the call parameters in the call request, thereby improving the data connection efficiency between the client and the server.
[0083] In one embodiment, the method further includes:
[0084] At set intervals, scan the update time of the logic code segment corresponding to the type of the called parameter;
[0085] If the update time obtained by the scan is later than the update time obtained by the previous scan, obtain the logic code fragment corresponding to the type of the call parameter corresponding to the update time obtained by the scan;
[0086] Based on the logic code fragment corresponding to the type of the obtained call parameter, update the class corresponding to the type of the call parameter.
[0087] Here, the server scans the update time of the logic code segment corresponding to the type of the calling parameter at set intervals. In actual applications, the set interval can be one hour or two hours. If the update time obtained from the scan is later than the update time obtained from the previous scan, it indicates that the logic code segment corresponding to the type of the calling parameter has been updated or added. In order to ensure that the class corresponding to the type of the calling parameter and the logic code segment corresponding to the type of the calling parameter are synchronized, the server obtains the logic code segment corresponding to the type of the calling parameter with the update time obtained from the scan, and recompiles it based on the obtained logic code segment to obtain the updated class corresponding to the type of the calling parameter.
[0088] By obtaining the latest updated logic code snippet corresponding to the type of the call parameter when an update is detected, and updating the class corresponding to the type of the call parameter, the server can call the most accurate class, thus improving the accuracy of the request results returned to the client.
[0089] In one embodiment, before scanning the update time of the logic code segment corresponding to the type of the calling parameter at set intervals, the method further includes:
[0090] Save the types of the call parameters and their corresponding logic code snippets;
[0091] Save the type of the call parameters and their corresponding class.
[0092] Here, after writing the logic code snippet in the first interface, the type of the call parameter and the corresponding logic code snippet are stored in the database.
[0093] After the server compiles the logic code snippets corresponding to the types of the call parameters into classes, it saves the types of the call parameters and their corresponding classes. To correspond with the data structure of the input parameters in the client's call request, the types of the call parameters and their corresponding classes are also stored in a Map structure. This way, after parsing the types of the call parameters in the call request, the corresponding classes can be quickly found in this Map structure based on the type of the call parameter.
[0094] By saving the types of call parameters and their corresponding logic code snippets, as well as the types of call parameters and their corresponding classes, it is convenient to record the specific update time when the logic code snippet corresponding to the type of call parameter is updated. It is also convenient to update the class corresponding to the type of call parameter, and to quickly find the corresponding class based on the type of call parameter, thereby improving the efficiency of client-server integration.
[0095] Figure 2 The request processing method provided for the application embodiments of this application, such as Figure 2 As shown:
[0096] The frontend requests a universal API, which represents a unified configuration interface. The server parses the request parameters from the frontend's universal API request. After parsing, it obtains the type of the request parameter and determines the type of the logic code fragment that processes the request parameter. It checks whether the server has a logic code fragment corresponding to that type. If the server does not have a logic code fragment corresponding to that type, it returns an exception handling result to the client. If the server has a logic code fragment corresponding to that type, it executes the corresponding logic code fragment and returns the execution result. Finally, it returns a unified processing result.
[0097] Figure 3 Another request processing method provided for the application embodiments of this application, such as Figure 3 As shown:
[0098] When adding a new logic code snippet, a `logic` interface is created, and a `handle` method implementing this interface is defined within it. The specific logic code snippet is written in the `handle` method, and the type of the corresponding call parameter and the implementation string of the logic code snippet are stored in the database. The server periodically scans the database for the latest update time of the logic code snippets. If the update time obtained in the current scan is not greater than the update time of the previous scan, no action is taken. If the update time obtained in the current scan is greater than the update time of the previous scan, the logic code snippet corresponding to the call parameter type corresponding to the update time of the current scan is loaded from the database. The logic code snippet corresponding to the call parameter type in the database is dynamically compiled using `JavaStringCompile` to obtain the updated class corresponding to the call parameter type. The class corresponding to the call parameter type is then updated in the database, thus making the logic code snippet callable.
[0099] In this embodiment, by receiving a client's call request to a designated interface, the type of the call parameters in the call request is determined. The designated interface supports at least two different types of call parameters. Then, based on the logic code fragment corresponding to the type of call parameter, the corresponding call result is returned to the client. In this way, the server can respond to call requests using different types of call parameters through a single designated interface, eliminating the need to develop different interfaces for different call requests, thus saving the overhead of interface development and improving the efficiency of interface development.
[0100] To implement the method of the embodiments of this application, the embodiments of this application also provide a request processing apparatus. Figure 4 For a schematic diagram of the request processing apparatus provided in the embodiments of this application, please refer to [link / reference]. Figure 4 The device includes:
[0101] The receiving unit 401 is used to receive a client's call request for a set interface; the set interface supports at least two different types of call parameters;
[0102] Determining unit 402 is used to determine the type of the calling parameters in the calling request;
[0103] The return unit 403 is used to return the corresponding call result to the client based on the logic code fragment corresponding to the type of the call parameter.
[0104] In one embodiment, the return unit 403 is further configured to execute the logical code segment corresponding to the type of the call parameter by calling the class corresponding to the type of the call parameter, and obtain the call result;
[0105] The call result is returned to the client; wherein,
[0106] The class corresponding to the type of the calling parameter is compiled from the logic code fragment corresponding to the type of the calling parameter.
[0107] In one embodiment, the apparatus further includes: an execution unit, configured to query among all classes implementing the first interface whether a class corresponding to the type of the calling parameter exists, and obtain a query result;
[0108] If the query result indicates the existence of a class corresponding to the type of the calling parameter, the logic code segment corresponding to the type of the calling parameter is executed by calling the class corresponding to the type of the calling parameter.
[0109] In one embodiment, the apparatus further includes: a creation unit for creating a first interface;
[0110] Create at least one method in the first interface;
[0111] In each of the at least one methods, a logic code fragment corresponding to the type of the calling parameter is written.
[0112] In one embodiment, the apparatus further includes: an update unit, configured to scan the update time of the logic code segment corresponding to the type of the calling parameter at set intervals;
[0113] If the update time obtained by the scan is later than the update time obtained by the previous scan, obtain the logic code fragment corresponding to the type of the call parameter corresponding to the update time obtained by the scan;
[0114] Based on the logic code fragment corresponding to the type of the obtained call parameter, update the class corresponding to the type of the call parameter.
[0115] In one embodiment, the apparatus further includes: a storage unit for storing the type of the calling parameters and the corresponding logic code fragments;
[0116] Save the type of the call parameters and their corresponding class.
[0117] In one embodiment, the return unit 403 is further configured to return an exception handling result to the client if the query result indicates that there is no class corresponding to the type of the calling parameter.
[0118] In practical applications, the receiving unit 401, the determining unit 402, the returning unit 403, the executing unit, the creating unit, the updating unit, and the saving unit can be implemented by a processor in the terminal, such as a central processing unit (CPU), a digital signal processor (DSP), a microcontroller unit (MCU), or a field-programmable gate array (FPGA).
[0119] It should be noted that the request processing device provided in the above embodiments is only illustrated by the division of the above program modules when displaying information. In actual applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device can be divided into different program modules to complete all or part of the processing described above. In addition, the request processing device and the request processing method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0120] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiments of this application, the embodiments of this application also provide an electronic device. Figure 5 This is a schematic diagram of the hardware composition structure of the electronic device provided in the embodiments of this application, such as... Figure 5 As shown, the electronic device includes:
[0121] The communication interface 501 enables information exchange with other devices, such as network devices.
[0122] The processor 502 is connected to the communication interface 501 to enable information interaction with other devices and, when running a computer program, executes the methods provided by one or more of the aforementioned terminal-side technical solutions. The computer program is stored in the memory 503.
[0123] Specifically, the processor 502 is used to receive a client's call request for a set interface; the set interface supports at least two different types of call parameters;
[0124] Determine the type of the call parameters in the call request;
[0125] Based on the logic code fragment corresponding to the type of the calling parameters, the corresponding calling result is returned to the client.
[0126] In one embodiment, the communication interface 501 is further configured to execute the logic code segment corresponding to the type of the calling parameter by calling the class corresponding to the type of the calling parameter, and obtain the calling result;
[0127] The call result is returned to the client; wherein,
[0128] The class corresponding to the type of the calling parameter is compiled from the logic code fragment corresponding to the type of the calling parameter.
[0129] In one embodiment, the processor 502 is further configured to query among all classes implementing the first interface whether there exists a class corresponding to the type of the calling parameter, and obtain a query result;
[0130] If the query result indicates the existence of a class corresponding to the type of the calling parameter, the logic code segment corresponding to the type of the calling parameter is executed by calling the class corresponding to the type of the calling parameter.
[0131] In one embodiment, before receiving a client's request to call the designated interface, the processor 502 is further configured to create a first interface;
[0132] Create at least one method in the first interface;
[0133] In each of the at least one methods, a logic code fragment corresponding to the type of the calling parameter is written.
[0134] In one embodiment, the processor 502 is further configured to scan the update time of the logic code segment corresponding to the type of the calling parameter at set intervals;
[0135] If the update time obtained by the scan is later than the update time obtained by the previous scan, obtain the logic code fragment corresponding to the type of the call parameter corresponding to the update time obtained by the scan;
[0136] Based on the logic code fragment corresponding to the type of the obtained call parameter, update the class corresponding to the type of the call parameter.
[0137] In one embodiment, before scanning the update time of the logic code segment corresponding to the type of the calling parameter at set intervals, the processor 502 is also used to save the type of the calling parameter and the corresponding logic code segment;
[0138] Save the type of the call parameters and their corresponding class.
[0139] In one embodiment, the processor 502 is further configured to return an exception handling result to the client if the query result indicates that there is no class corresponding to the type of the calling parameter.
[0140] Of course, in practical applications, the various components in an electronic device are coupled together through a bus system 504. It can be understood that the bus system 504 is used to realize the connection and communication between these components. In addition to a data bus, the bus system 504 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, in... Figure 5 The general designated all buses as Bus System 504.
[0141] The memory 503 in this embodiment is used to store various types of data to support the operation of the electronic device. Examples of such data include any computer program used to operate on the electronic device.
[0142] It is understood that memory 503 can be volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); magnetic surface memory can be disk storage or magnetic tape storage. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memory 503 described in the embodiments of this application is intended to include, but is not limited to, these and any other suitable types of memory.
[0143] The methods disclosed in the embodiments of this application can be applied to or implemented by the processor 502. The processor 502 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in the processor 502 or by instructions in the form of software. The processor 502 may be a general-purpose processor, a DSP, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor 502 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, which is located in the memory 503. The processor 502 reads the program in the memory 503 and combines it with its hardware to complete the steps of the aforementioned method.
[0144] When processor 502 executes the program, it implements the corresponding processes in the various methods of the embodiments of this application.
[0145] In an exemplary embodiment, this application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, such as a memory 503 storing a computer program, which can be executed by a processor 502 to complete the steps described in the aforementioned method. The computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disc, or CD-ROM.
[0146] In the several embodiments provided in this application, it should be understood that the disclosed apparatus, terminal, and method can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.
[0147] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.
[0148] In addition, each functional unit in the various embodiments of this application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.
[0149] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
[0150] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
[0151] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A request processing method, characterized in that, Applied to a server, the method includes: The server receives a client's call request for a defined interface; the defined interface supports at least two different types of call parameters; the server can respond to call requests using different types of call parameters through one defined interface; wherein, the data structure of the input parameters of the call request is a Map structure, the Map is a collection of key-value pairs, which is an associative array that associates the value of an element with a specific key, and the Map contains a parameter type, which represents the type of call parameters in the call request; Determine the type of the call parameters in the call request; Based on the logic code fragment corresponding to the type of the call parameter, the corresponding call result is returned to the client; Prior to receiving the client's request to call the designated interface, the method further includes: Create a first interface; the first interface is not the same as the defined interface; the defined interface is a Hypertext Transfer Protocol interface or a Remote Procedure Call interface; Create at least one method in the first interface; In each of the at least one methods, a logic code fragment corresponding to the type of the calling parameter is written.
2. The request processing method according to claim 1, characterized in that, The logic code fragment corresponding to the type of the calling parameter returns the corresponding calling result to the client, including: By calling the class corresponding to the type of the calling parameter, the logic code segment corresponding to the type of the calling parameter is executed to obtain the calling result; The call result is returned to the client; wherein, The class corresponding to the type of the calling parameter is compiled from the logic code fragment corresponding to the type of the calling parameter.
3. The request processing method according to claim 2, characterized in that, The step of executing the logical code fragment corresponding to the type of the calling parameter by calling the class corresponding to the type of the calling parameter includes: Search among all classes that implement the first interface to find if there exists a class corresponding to the type of the calling parameter, and obtain the query results; If the query result indicates that a class corresponding to the type of the calling parameter exists, the logical code segment corresponding to the type of the calling parameter is executed by calling the class corresponding to the type of the calling parameter.
4. The request processing method according to claim 2, characterized in that, The method further includes: At set intervals, scan the update time of the logic code segment corresponding to the type of the called parameter; If the update time obtained by the scan is later than the update time obtained by the previous scan, obtain the logic code fragment corresponding to the type of the call parameter corresponding to the update time obtained by the scan; Based on the logic code fragment corresponding to the type of the obtained call parameter, update the class corresponding to the type of the call parameter.
5. The request processing method according to claim 4, characterized in that, Before scanning the update time of the logic code fragment corresponding to the type of the calling parameter at set intervals, the method further includes: Save the types of the call parameters and their corresponding logic code snippets; Save the type of the call parameters and their corresponding class.
6. The request processing method according to claim 3, characterized in that, The method further includes: If the query result indicates that there is no class corresponding to the type of the calling parameter, an exception handling result is returned to the client.
7. A request processing apparatus, characterized in that, The device includes: A receiving unit is used to receive a client's call request for a set interface; the set interface supports at least two different types of call parameters; wherein, one of the set interfaces enables the server to respond to call requests using different types of call parameters; wherein, the data structure of the input parameters of the call request is a Map structure, the Map is a collection of key-value pairs, which is an associative array that associates the value of an element with a specific key, and the Map contains a parameter type, which represents the type of call parameter in the call request; A determining unit is used to determine the type of the calling parameters in the calling request; The return unit is used to return the corresponding call result to the client based on the logic code fragment corresponding to the type of the call parameter; A creation unit is used to create a first interface before receiving a client's call request for a designated interface; create at least one method in the first interface; and write a logic code fragment corresponding to the type of a call parameter in each of the at least one method; the first interface and the designated interface are not the same interface; the designated interface is a Hypertext Transfer Protocol interface or a Remote Procedure Call interface.
8. An electronic device, characterized in that, include: A processor and memory for storing computer programs that can run on the processor, wherein, When the processor is used to run the computer program, it performs the steps of the method according to any one of claims 1-6.
9. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1-6.
Citation Information
Patent Citations
Method for calling programmable interfaces and terminal
CN107783804A