Method, device, computer equipment and storage medium for processing network request data
By acquiring and classifying storage parameters in the network request framework and combining them with back-end conditional processing of the parameter body, the redundant code problem caused by the secondary encapsulation of the network request framework is solved, and efficient unified encapsulation and flexible configuration of network requests are achieved.
Patent Information
- Application Number
- CN202211083779.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-06
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2042-09-06
AI Technical Summary
In the existing technology, the secondary packaging process of the network request framework requires the injection of a large amount of redundant and necessary code, which increases the difficulty and complexity of development. Especially when facing complex and diverse demand scenarios and different server-side encryption and decryption schemes, it leads to the diversity of interface request parameters and the inconsistency of server-side encryption and decryption schemes.
By obtaining the configuration data within the network request framework, receiving and classifying and storing various types of network request parameters, generating the parameter body required for the network request, and processing it in combination with the initiation conditions agreed upon by the backend, the network request parameters are uniformly encapsulated to reduce redundant code and code logic.
It greatly reduces the redundant code required to adapt to different types of network parameters, reduces development difficulty and complexity, and improves the flexibility of network request configuration.
Smart Images

Figure CN115442442B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device, computer equipment and storage medium for processing network request data. Background Art
[0002] Network requests are a fundamental module used in both front-end and back-end development. HTTP clients are commonly used network request tools for calling other services. Typically, services expose HTTP interfaces, and common HTTP request types include GET, PUT, POST, and DELETE. While network request tools offer powerful and flexible functionality, they can also be complex to configure in practice, requiring the generation of redundant code for different scenarios.
[0003] In the related art, in order to solve the problem of redundant code in most scenarios, a solution for secondary packaging of the network request framework is provided. The specific secondary packaging process is mainly for information such as request parameters, request field header parameters, address parameters, and return result processing in the network request framework, and the request process is completed by the network request tool. However, in the face of complex and diverse demand scenarios and different server-side encryption and decryption schemes, there will be a diversity of different interface request parameters and inconsistency of server-side encryption and decryption schemes. For example, in the case of plain text, files, local file addresses, mixed file texts, multi-level parameters, etc. of the request parameters, a lot of adaptation work needs to be done on the interface of the dynamic proxy in the secondary packaging process of the network request framework. At the same time, a lot of redundant and necessary code needs to be injected to handle the interface adaptation work, which increases the difficulty and complexity of development. Summary of the Invention
[0004] In view of this, the present invention provides a method, device, computer equipment and storage medium for processing network request data. The main purpose is to solve the problem in the prior art that the secondary packaging process of the network request framework requires the injection of a large amount of redundant and necessary code to handle interface adaptation work, which increases the difficulty and complexity of development.
[0005] According to one aspect of the present invention, a method for processing network request data is provided, comprising:
[0006] Get the configuration data saved in the network request framework;
[0007] Receive various types of network request parameters, and classify and store the various types of network request parameters into an array;
[0008] When the front end initiates a network request, by parsing the types corresponding to the network request parameters in the array, the network request parameters are packaged according to the types corresponding to the network request parameters to generate the parameter body required for the network request;
[0009] The configuration data is called in combination with the initiation conditions agreed upon by the backend to process the parameter body, and a network request is initiated to the backend using the processed parameter body.
[0010] According to another aspect of the present invention, a device for processing network request data is provided, comprising:
[0011] The acquisition module is used to obtain the configuration data saved in the network request framework;
[0012] A storage module, configured to receive various types of network request parameters and classify and store the various types of network request parameters into an array;
[0013] A generating module is configured to initiate a network request at the current end, parse the types corresponding to the network request parameters in the array, and package the network request parameters according to the types corresponding to the network request parameters to generate a parameter body required for the network request;
[0014] The initiation module is used to call the configuration data to process the parameter body in combination with the initiation conditions agreed upon by the backend, and use the processed parameter body to initiate a network request to the backend.
[0015] According to another aspect of the present invention, a computer device is provided, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method for processing network request data when executing the computer program.
[0016] According to another aspect of the present invention, a computer storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for processing network request data are implemented.
[0017] By means of the above technical solution, the present invention provides a method, device, computer equipment and storage medium for processing network request data, which receives various types of network request parameters by obtaining the configuration data stored in the network request framework, and classifies and stores the various types of network request parameters into an array. When the front end initiates a network request, the network request parameters are packaged according to the types corresponding to the network request parameters by parsing the types corresponding to the network request parameters in the array to generate the parameter body required for the network request. The parameter body is processed by calling the configuration data in combination with the initiation conditions agreed upon by the back end, and the processed parameter body is used to initiate a network request to the back end. Compared with the prior art method of performing secondary encapsulation on the network request framework, the network request framework in the present application can classify and store various types of network request parameters, and after the front end initiates the network request, it can uniformly encapsulate various types of network request parameters required for the network request, which greatly reduces the redundant code required to adapt to different types of network parameters, while reducing the amount of code and code logic, thereby reducing the difficulty and complexity of development. It can also determine the content of the configuration data in combination with the initiation conditions agreed upon by the back end, thereby improving the flexibility of the network request configuration. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Various other advantages and benefits will become apparent to those skilled in the art upon reading the detailed description of the preferred embodiment below. The accompanying drawings are for illustration purposes only and are not to be considered as limiting the present invention. The same reference symbols are used throughout the drawings to represent the same components. In the drawings:
[0019] Figure 1 This is a schematic diagram of an application environment of a method for processing network request data in one embodiment of the present invention;
[0020] Figure 2 This is a flow chart of a method for processing network request data in one embodiment of the present invention;
[0021] Figure 3 yes Figure 2 A schematic flow chart of a specific implementation of step S10;
[0022] Figure 4 yes Figure 2 A schematic flow chart of a specific implementation of step S20;
[0023] Figure 5 It is a structural diagram of a device for processing network request data in one embodiment of the present invention;
[0024] Figure 6 is a structural diagram of a computer device in one embodiment of the present invention;
[0025] Figure 7FIG. 2 is another structural diagram of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0026] Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0027] The method for processing network request data provided by the embodiment of the present invention can be applied in the following situations: Figure 1 In an application environment, the client communicates with the server through a network. The client can obtain the configuration data stored in the network request framework, receive various types of network request parameters, and classify and store the various types of network request parameters in an array. When the front end initiates a network request, it parses the types corresponding to the network request parameters in the array, packages the network request parameters according to the types corresponding to the network request parameters, generates the parameter body required for the network request, calls the configuration data in combination with the initiation conditions agreed upon by the back end, processes the parameter body, and uses the processed parameter body to initiate a network request to the back end. In the present invention, the network request framework can classify and store various types of network request parameters, and after the front end initiates the network request, it can uniformly encapsulate the various types of network request parameters required for the network request, greatly reducing the redundant code required to adapt to different types of network parameters, while reducing the amount of code and code logic, thereby reducing development difficulty and complexity. The content of the configuration data can also be determined in combination with the initiation conditions agreed upon by the back end, thereby improving the flexibility of network request configuration. The client can be, but is not limited to, various personal computers, laptops, smartphones, tablet computers, and portable wearable devices. The server can be implemented as an independent server or a server cluster consisting of multiple servers. The present invention is described in detail below through specific embodiments.
[0028] See also Figure 2 As shown, Figure 2 A flowchart of a method for processing network request data provided by an embodiment of the present invention includes the following steps:
[0029] S10. Obtain configuration data stored in the network request framework.
[0030] The method for processing network request data provided by the present invention can be applied to network request processes initiated by clients in various scenarios, such as network requests initiated by user login and network requests initiated by user accessing a page. In project development, network requests are a crucial link. It is necessary to uniformly encapsulate the request method to facilitate calling in the project without repeating the network request method in every place where a network request is required. A universal network request framework, Retrofit, can be used here. Retrofit is an http framework suitable for Android and Java, and is usually used to make network connection calls.
[0031] It is understandable that the network request framework here can configure network requests and network request parameters for different network request methods through annotations. The network request methods here can be GET, POST, PUT, DELETE, etc., and the network request parameters can be URL, Path, Part, Query, etc. The network request of each network request method has an http annotation, which provides the request method and relative URL path, and places the network request parameters in the annotation.
[0032] The configuration data stored within the network request framework can include various types of network request configuration data, such as HTTP certificates, network timeouts, server encryption and decryption methods, and DNS resolution questions. The specific implementation of the encryption and decryption methods depends on the encryption and decryption scheme agreed upon by the proxy class's server. It should be noted that this configuration data is used by default during the network request process. If no configuration changes are made to subsequent network requests, the default configuration data will be used to initiate the network request.
[0033] It should be understood that the configuration data of the network request process can use the default configuration data, and can also use configuration instructions to modify the default configuration data to flexibly configure the network request process. Specifically, Figure 3 In step S10, that is, obtaining the configuration data stored in the network request framework, the following steps are included:
[0034] S11. Obtain a proxy class created by the backend for the network request framework, and use the proxy class as the overall control center for processing network requests.
[0035] S12: If no configuration instruction of the network request framework is received, the default data is saved in the network request framework as configuration data of the network request process.
[0036] Typically, before using a network request framework, some basic configuration data is required to optimize network requests. This includes configuring JSON converters, RxJava adapters, timeouts, and error reconnection. This configuration data can be exposed and stored using a proxy class created by the framework. This proxy class can then be used to handle different types of network requests. The framework then constructs a network request entity class and injects the configuration data into it. The proxy class created by the framework uses a dynamic proxy model to provide a functional interface to the outside world, enabling unified management of network request access objects. For example, diverse access scenarios can be inconvenient for users or system architectures. When receiving access objects for different types of network requests, adding a specific interface for each type of access object allows for unified management of access objects. The network request entity class consists of a method constructed around the attributes and parameters of the network request. This method then assigns values to the corresponding attribute parameters for each network request. For example, network request parameters may include the user request ID, the user's category, and the query category.
[0037] It is understandable that the default configuration data in the network request framework may not meet the security requirements of network request data during transmission. Custom settings can also be made through configuration instructions. Specifically, if a configuration instruction from the network request framework is received, the creation mode is used within the proxy class of the network request frame to construct the entity class of the network request frame, and the configuration data for the network request process is dynamically injected into the entity class of the network request frame. For example, Retrofit.build() is used in the proxy class of the network request frame to construct a Retrift entity class, and configuration data such as the http certificate, network timeout period, and service encryption and decryption methods are dynamically injected into the Retrift entity class.
[0038] S20: Receive various types of network request parameters, and classify and store the various types of network request parameters into an array.
[0039] In an embodiment of the present invention, before a network request is initiated, it is often necessary to obtain the form data submitted by the user, such as user name, password, email, etc. In order to facilitate the acquisition of network request parameters in the form, a series of methods for obtaining request parameters can be defined in the request interface. For example, the string getmethod() method is declared to obtain the request method in the http request message, and the string getScheme() method is declared to obtain the protocol name of the request, such as http, https or ftp.
[0040] Here, you can maintain arrays for storing various types of network request parameters internally in the network request framework, and classify and store various types of network request parameters in the arrays. For example, use array A to maintain network request parameters of data types, including text, numbers, Boolean values, enumerations, etc., use array B to maintain network request parameters of file types, including file streams and file addresses, and use array C to maintain network request parameters of JSON object types.
[0041] It should be understood that each time before initiating a network request, the front end will define the request format for different types of network request parameters, and receive various types of network request parameters according to the request format, and send the network request parameters. Figure 4 As shown, in step S20, that is, receiving various types of network request parameters and classifying and storing the various types of network request parameters into an array, the following steps are included:
[0042] S21. Various types of network request parameters are uniformly received through the encapsulation class of the customized network request.
[0043] S22. Classify the various types of network request parameters and store them in an array in sequence through type identification.
[0044] Specifically, before each network request is initiated, a custom encapsulation class can be used to uniformly receive various types of network request parameters. The encapsulation class consists of four arrays for storing data and an identifier for controlling encryption and decryption. The encapsulation class provides a unique put method to receive various types of network request parameters. The encapsulation class will identify the types corresponding to the network request parameters in turn and place the network request parameters in arrays of the corresponding types. For example, if the network request parameter is identified as a text data type, the network request parameter will be placed in the array of the data type.
[0045] Furthermore, considering the security of network request data during transmission, you can set here whether the network request executes the encryption and decryption method body. For network requests that execute the encryption and decryption method body, it is also necessary to call the encryption method for encryption processing during the processing of the network request parameters. Similarly, for network requests that execute the decryption method body, it is also necessary to call the decryption method body for decryption processing of the request return data.
[0046] S30: When the current end initiates a network request, the network request parameters in the array are parsed into corresponding types, and the network request parameters are packaged according to the corresponding types to generate a parameter body required for the network request.
[0047] Since various types of network requests include data types, file types, and JSON object types, for different types of network requests, specifically, when the type corresponding to the network request parameter only contains data types or JSON object types, a new JSON format data structure can be generated to traverse and read the parameter array storing the data type, and merge the parameter array into the JSON format data structure, and the merged parameter array is packaged to generate the parameter body required for the network request; when the type corresponding to the network request parameter contains a file type or a mixture of data type and file type, a new JSON format data structure can be generated to traverse and read the parameter array storing the data type, and merge the parameter array of the data type into the JSON format data structure, and merge the parameter array storing the file type into the JSON format data structure through the add method provided by the network request framework, and package the merged parameter array to generate the parameter body required for the network request.
[0048] Specifically, the encapsulation class of the custom network request provides a single method, getBody(), which takes the network request parameters in the encapsulation class as input. getBody parses the array data held by the encapsulation class and determines the type of the array data. When there is only an array of a data type or an array of JSON objects, a new JSON format data structure is generated, and then the parameter array storing the data type is traversed and read, and the parameter array is merged into the newly generated JSON format data structure. The merged parameters are used to generate the parameter body required for the network request. For requests with arrays of file types or mixed arrays of data types and file class types, the data types are first encapsulated using the same steps as above, and then the newly generated JSON format data structure is merged into the data of the file address array and the file stream array using the adding method of the network request framework. The parameter body required for the network request is then generated using the merged parameters.
[0049] S40: Invoke the configuration data to process the parameter body in combination with the initiation condition agreed upon by the backend, and use the processed parameter body to initiate a network request to the backend.
[0050] Taking into account the use of different encryption and decryption schemes during network transmission, the initiation conditions of whether to use the encryption and decryption scheme can be agreed upon on the back end. If the initiation conditions agreed upon by the back end set the network request to execute the encryption method body, the configuration data can be called in combination with the initiation conditions agreed upon by the back end, and the encryption method body held by the proxy class created by the network request framework can be obtained. The parameter body is encrypted using the ciphertext string corresponding to the encryption method body, and the encrypted parameter body is used to initiate a network request to the back end. Here, the input parameter of the encryption method body is a data structure in JSON format, and the output parameter of the encryption method body is the encrypted ciphertext string. If the initiation conditions agreed upon by the back end set the network request to execute the decryption method body, after initiating the network request, when the network request framework intercepts the network return data, the decryption method body held by the proxy class created by the network request framework is obtained, and the network return data is decrypted using the ciphertext string corresponding to the decryption method body, and the decrypted network return data is sent to the network request framework. Here, the input parameter of the decryption method body is the encrypted ciphertext string, and the output parameter of the decryption method body is a data structure in JSON format.
[0051] Specifically, it is possible to determine whether the encapsulation class of the custom network request holds an encryption / decryption identifier in combination with the initiation conditions agreed upon by the backend. If the encapsulation class holds an encryption identifier, it is determined that the initiation conditions agreed upon by the backend are set with a network request to execute an encryption method body. If the encapsulation class holds a decryption identifier, it is determined that the initiation conditions determined by the backend are set with a network request to execute a decryption method body.
[0052] The present embodiment provides a method for processing network request data, which obtains the configuration data stored in the network request framework, receives various types of network request parameters before initiating the network request, and classifies and stores the various types of network request parameters in an array. When the front end initiates the network request, the network request parameters are packaged according to the types corresponding to the network request parameters by parsing the types corresponding to the network request parameters in the array to generate the parameter body required for the network request, and the configuration data is called in combination with the initiation conditions agreed upon by the back end to process the parameter body, and the processed parameter body is used to initiate a network request to the back end. Compared with the prior art method of secondary encapsulation of the network request framework, the network request framework in the present application can classify and store various types of network request parameters, and after the front end initiates the network request, it can uniformly encapsulate various types of network request parameters required for the network request, which greatly reduces the redundant code required to adapt to different types of network parameters, while reducing the amount of code and code logic, thereby reducing the difficulty and complexity of development. It can also determine the content of the configuration data in combination with the initiation conditions agreed upon by the back end, thereby improving the flexibility of the network request configuration.
[0053] In one embodiment, a device for processing network request data is provided, and the device for processing network request data corresponds to the method for processing network request data in the above embodiment. Figure 5 As shown, the network request data processing device includes an acquisition module 101, a storage module 102, a generation module 103, and an initiation module 104. The functional modules are described in detail as follows:
[0054] The acquisition module 101 is used to obtain the configuration data stored in the network request framework;
[0055] The storage module 102 is configured to receive various types of network request parameters and classify and store the various types of network request parameters into an array;
[0056] The generating module 103 is configured to, when the current end initiates a network request, parse the types corresponding to the network request parameters in the array, and package the network request parameters according to the types corresponding to the network request parameters to generate a parameter body required for the network request;
[0057] The initiation module 104 is configured to process the parameter body by calling the configuration data in combination with the initiation conditions agreed upon by the backend, and initiate a network request to the backend using the processed parameter body.
[0058] In one embodiment, the acquisition module 101 is specifically used to obtain the proxy class created by the backend for the network request framework, and use the proxy class as the overall control center for processing network requests. The overall control center provides the default data required to save the network request process to the outside world; if the configuration instruction of the network request framework is not received, the default data is saved to the network request framework as the configuration data of the network request process.
[0059] In one embodiment, the acquisition module 101 is further used to construct an entity class of the network request framework using a creation pattern within the proxy class of the network request frame if a configuration instruction of the network request framework is received; and dynamically inject configuration data of the network request process into the entity class of the network request framework.
[0060] In one embodiment, the storage module 102 is specifically configured to uniformly receive various types of network request parameters through a custom network request encapsulation class; and sequentially classify and store the various types of network request parameters into an array through type identification.
[0061] In one embodiment, the various types of network requests include data types, file types, and JSON object types. When the type corresponding to the network request parameter only includes the data type or the JSON object type, the generation module 103 is specifically configured to traverse and read the parameter array storing the data type through a newly generated JSON format data structure, merge the parameter array into the JSON format data structure, and package the merged parameter array to generate a parameter body required for the network request;
[0062] When the type corresponding to the network request parameter includes a file type or the data type and the file type are mixed, the generation module 103 is specifically used to traverse and read the parameter array storing the data type through a newly generated JSON format data structure, and merge the parameter array of the data type into the JSON format data structure, merge the parameter array storing the file type into the JSON format data structure through the adding method provided by the network request framework, and package the merged parameter array to generate the parameter body required for the network request.
[0063] In one embodiment, if the initiation condition agreed upon by the backend sets a network request to execute an encrypted method body, the initiation module 104 is specifically configured to call the configuration data in combination with the initiation condition agreed upon by the backend, obtain the encrypted method body held by the proxy class created by the network request framework, encrypt the parameter body using the ciphertext string corresponding to the encrypted method body, and use the encrypted parameter body to initiate a network request to the backend, wherein the input parameter of the encrypted method body is a data structure in JSON format, and the output parameter of the encrypted method body is the encrypted ciphertext string;
[0064] If the initiation condition agreed upon by the backend sets a network request to execute a decryption method body, the initiation module 104 is further used to call the configuration data to process the parameter body in combination with the initiation condition agreed upon by the backend, and after using the processed parameter body to initiate a network request to the backend, when the network request framework intercepts the network return data, obtain the decryption method body held by the proxy class created by the network request framework, use the ciphertext string corresponding to the decryption method body to decrypt the network return data, and send the decrypted network return data to the network request framework, the input parameter of the decryption method body is the encrypted ciphertext string, and the output parameter of the decryption method body is a data structure in JSON format.
[0065] In one embodiment, the initiation module is further used to determine whether the encapsulation class of the custom network request holds an encryption / decryption identifier in combination with the initiation conditions agreed upon by the backend; if the encapsulation class holds an encryption identifier, it is determined that the initiation conditions agreed upon by the backend are set with a network request to execute an encryption method body; if the encapsulation class holds a decryption identifier, it is determined that the initiation conditions determined by the backend are set with a network request to execute a decryption method body.
[0066] The present embodiment provides a device for processing network request data, which obtains the configuration data stored in the network request framework, receives various types of network request parameters before initiating the network request, and classifies and stores the various types of network request parameters into an array. When the front end initiates the network request, the network request parameters are packaged according to the types corresponding to the network request parameters by parsing the types corresponding to the network request parameters in the array to generate the parameter body required for the network request, and the configuration data is called in combination with the initiation conditions agreed upon by the back end to process the parameter body, and the processed parameter body is used to initiate the network request to the back end. Compared with the prior art method of secondary encapsulation of the network request framework, the network request framework in the present application can classify and store various types of network request parameters, and after the front end initiates the network request, it can uniformly encapsulate the various types of network request parameters required for the network request, which greatly reduces the redundant code required to adapt to different types of network parameters, while reducing the amount of code and code logic, thereby reducing the difficulty and complexity of development. It can also determine the content of the configuration data in combination with the initiation conditions agreed upon by the back end, thereby improving the flexibility of the network request configuration.
[0067] For the specific definition of the network request data processing device, please refer to the definition of the network request data processing method above, which will not be repeated here. The various modules in the above-mentioned network request data processing device can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0068] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 6As shown. The computer device includes a processor, memory, network interface and database connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external client via a network connection. When the computer program is executed by the processor, it implements the functions or steps on the server side of a method for processing network request data.
[0069] In one embodiment, a computer device is provided. The computer device may be a client, and its internal structure diagram may be as follows: Figure 7 As shown. The computer device includes a processor, memory, network interface, display screen and input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it implements the functions or steps of the client side of a method for processing network request data.
[0070] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are performed:
[0071] Get the configuration data saved in the network request framework;
[0072] Receive various types of network request parameters, and classify and store the various types of network request parameters into an array;
[0073] When the front end initiates a network request, by parsing the types corresponding to the network request parameters in the array, the network request parameters are packaged according to the types corresponding to the network request parameters to generate the parameter body required for the network request;
[0074] The configuration data is called in combination with the initiation conditions agreed upon by the backend to process the parameter body, and a network request is initiated to the backend using the processed parameter body.
[0075] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0076] Get the configuration data saved in the network request framework;
[0077] Receive various types of network request parameters, and classify and store the various types of network request parameters into an array;
[0078] When the front end initiates a network request, by parsing the types corresponding to the network request parameters in the array, the network request parameters are packaged according to the types corresponding to the network request parameters to generate the parameter body required for the network request;
[0079] The configuration data is called in combination with the initiation conditions agreed upon by the backend to process the parameter body, and a network request is initiated to the backend using the processed parameter body.
[0080] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or computer device can be found in the relevant descriptions of the server side and the client side in the aforementioned method embodiment. To avoid repetition, they will not be described one by one here.
[0081] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0082] Those skilled in the art will clearly understand that for the sake of convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0083] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention, and should all be included in the scope of protection of the present invention.
Claims
1. A method for processing network request data, characterized in that: The method comprises: Obtain the configuration data stored in the network request framework. The network request framework configures network requests and network request parameters for different network request methods through annotations. The configuration data is used by default during the network request process. If no configuration changes are made to subsequent network requests, the default configuration data is used to initiate a network request during the network request process. Receive various types of network request parameters and classify and store the various types of network request parameters into an array, wherein the various types of network requests include data types, file types, and JSON object types; When the front end initiates a network request, by parsing the type corresponding to the network request parameter in the array, when the type corresponding to the network request parameter only contains the data type or the JSON object type, a new JSON format data structure is generated, the parameter array storing the data type is traversed and read, and the parameter array is merged into the data structure in the JSON format, and the merged parameter array is packaged to generate the parameter body required for the network request; when the type corresponding to the network request parameter contains the file type or the data type is mixed with the file type, a new JSON format data structure is generated, the parameter array storing the data type is traversed and read, and the parameter array of the data type is merged into the data structure in the JSON format, and the parameter array storing the file type is merged into the data structure in the JSON format by the adding method provided by the network request framework, and the merged parameter array is packaged to generate the parameter body required for the network request; The configuration data is called in combination with the initiation conditions agreed upon by the backend to process the parameter body, and a network request is initiated to the backend using the processed parameter body.
2. The method according to claim 1, characterized in that The configuration data stored in the network request framework is obtained, including: Obtaining a proxy class created by the backend for the network request framework, using the proxy class as a general control center for processing network requests, and the general control center providing externally with default data required for saving the network request process; If no configuration instruction of the network request framework is received, the default data is saved to the network request framework as configuration data for the network request process.
3. The method according to claim 2, characterized in that The method further comprises: If a configuration instruction of a network request framework is received, an entity class of the network request framework is constructed using a creation mode in a proxy class of the network request framework; Dynamically inject the configuration data of the network request process into the entity class of the network request framework.
4. The method according to claim 1, wherein The receiving various types of network request parameters and classifying and storing the various types of network request parameters into an array includes: Receive various types of network request parameters uniformly through custom network request encapsulation classes; The various types of network request parameters are classified and stored in an array in sequence through type identification.
5. The method according to any one of claims 1 to 4, characterized in that If the initiation condition agreed upon by the backend sets a network request to execute an encryption method body, then the configuration data is called in combination with the initiation condition agreed upon by the backend to process the parameter body, and the processed parameter body is used to initiate a network request to the backend, including: The configuration data is called in combination with the initiation conditions agreed upon by the backend, the encryption method body held by the proxy class created by the network request framework is obtained, the parameter body is encrypted using the ciphertext string corresponding to the encryption method body, and the encrypted parameter body is used to initiate a network request to the backend. The input parameter of the encryption method body is a data structure in JSON format, and the output parameter of the encryption method body is the encrypted ciphertext string; If the initiation condition agreed upon by the backend sets a network request to execute a decryption method body, then after calling the configuration data in combination with the initiation condition agreed upon by the backend to process the parameter body and initiating a network request to the backend using the processed parameter body, the method further includes: When the network request framework intercepts the network return data, the decryption method body held by the proxy class created by the network request framework is obtained, the network return data is decrypted using the ciphertext string corresponding to the decryption method body, and the decrypted network return data is sent to the network request framework. The input parameter of the decryption method body is the encrypted ciphertext string, and the output parameter of the decryption method body is a data structure in JSON format.
6. The method according to claim 5, characterized in that The method further comprises: Combined with the initiation conditions agreed upon by the backend, determine whether the encapsulation class of the custom network request holds the encryption / decryption flag; If the encapsulation class holds an encryption identifier, it is determined that the initiation condition agreed upon by the backend is set with a network request to execute an encryption method body; If the encapsulation class holds a decryption identifier, it is determined that the initiation condition determined by the backend is set with a network request to execute the decryption method body.
7. A device for processing network request data, characterized in that: The device comprises: An acquisition module is used to obtain configuration data stored in the network request framework. The network request framework configures network requests and network request parameters for different network request methods through annotations. The configuration data is used by default during the network request process. If no configuration changes are made to subsequent network requests, the default configuration data is used to initiate a network request during the network request process. A storage module is used to receive various types of network request parameters and classify and store the various types of network request parameters into an array, wherein the various types of network requests include data types, file types, and JSON object types; A generation module is used to initiate a network request from the front end, and parse the type corresponding to the network request parameter in the array. When the type corresponding to the network request parameter only contains a data type or a JSON object type, a new JSON format data structure is generated, and the parameter array storing the data type is traversed and read, and the parameter array is merged into the data structure in the JSON format, and the merged parameter array is packaged to generate the parameter body required for the network request; when the type corresponding to the network request parameter contains a file type or a mixture of a data type and a file type, a new JSON format data structure is generated, and the parameter array storing the data type is traversed and read, and the parameter array of the data type is merged into the data structure in the JSON format, and the parameter array storing the file type is merged into the data structure in the JSON format through the adding method provided by the network request framework, and the merged parameter array is packaged to generate the parameter body required for the network request; The initiation module is used to call the configuration data to process the parameter body in combination with the initiation conditions agreed upon by the backend, and use the processed parameter body to initiate a network request to the backend.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Network requesting method and system for IOS (Internet work 0perating System), storage medium and electronic equipment
CN108681448A