HTTP instance generation method and device, equipment and medium
By generating HTTP requests to send encapsulation classes and request and response logic processing encapsulation classes, automatically generating and automatically sending HTTP instances, the problem of HTTP requests relying on configuration proxy in the existing technology is solved, and the separation of the business layer and the logic layer code is achieved and the development efficiency is improved.
Patent Information
- Application Number
- CN202411958465.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-04-25
AI Technical Summary
Existing HTTP requests can only be implemented based on the configuration proxy, and confusion between the business layer and the logic layer code is not conducive to maintenance.
The encapsulation class is sent based on the network request library and the encapsulation class is processed by generating HTTP requests and sending the encapsulation class by processing the encapsulation class based on the target service address or pre-configured proxy association data, and the encapsulation class sending request is sent using the HTTP request.
It realizes automatic generation and automatic sending of HTTP instances, breaks the dependence on configuration proxy, separates the business layer and the logic layer code, and improves development efficiency.
Smart Images

Figure CN119892813A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software development, and in particular to a HTTP instance generation method, device, equipment and medium. Background Art
[0002] Generally, in web (world wide web, global wide area network) projects using vue (front-end framework for building user interfaces), sending HTTP (HyperText Transfer Protocol) requests is usually implemented by using axios (a network request library based on promise) plus configuring a proxy. This method requires the corresponding proxy to be configured in the web service container for forwarding, which is not flexible enough. At the code level, business code and HTTP module code are mixed together, which is not conducive to maintenance and expansion. Summary of the invention
[0003] The present invention provides an HTTP instance generation method, device, equipment and medium to solve the problem that the existing HTTP request can only be implemented based on the configuration proxy mode, and the business layer and the logic layer code are confused and not conducive to maintenance.
[0004] According to one aspect of the present invention, there is provided a method for generating an HTTP instance, comprising:
[0005] Generate HTTP request sending encapsulation class based on network request library, and create request and response logic processing encapsulation class;
[0006] According to the target service address or pre-configured proxy association data, the request and response logic processing encapsulation class is called through the instance generation module to generate the target HTTP instance;
[0007] Use the HTTP request sending encapsulation class to send the request corresponding to the target HTTP instance.
[0008] According to another aspect of the present invention, there is provided an HTTP instance generation device, comprising:
[0009] The encapsulation class creation module is used to generate a hypertext transfer protocol HTTP request sending encapsulation class based on the network request library, and create a request and response logic processing encapsulation class;
[0010] HTTP instance generation module, used to generate a target HTTP instance by calling the request and response logic processing encapsulation class through the instance generation module according to the target service address or pre-configured proxy association data;
[0011] The request sending module is used to send the request corresponding to the target HTTP instance by using the HTTP request sending encapsulation class.
[0012] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0013] at least one processor; and
[0014] a memory communicatively connected to the at least one processor; wherein,
[0015] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the HTTP instance generation method described in any embodiment of the present invention.
[0016] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the HTTP instance generation method described in any embodiment of the present invention when executed.
[0017] The technical solution of the embodiment of the present invention generates an HTTP request sending encapsulation class based on a network request library, and creates a request and response logic processing encapsulation class, so that according to the target service address or pre-configured proxy association data, the request and response logic processing encapsulation class is called through the instance generation module to generate a target HTTP instance, and then the HTTP request sending encapsulation class is used to send the request corresponding to the target HTTP instance. In this solution, the HTTP instance can be automatically generated by calling the request and response logic processing encapsulation class through the instance generation module, and the HTTP request sending encapsulation class is used to automatically send the request corresponding to the target HTTP instance, and the dependence of HTTP instance generation on the configuration proxy is broken, and the problem that the existing HTTP request can only be implemented based on the configuration proxy, and the confusion of the business layer and the logic layer code is not conducive to maintenance is solved. The implementation method of HTTP requests can be expanded, and the separation of the business layer and the logic layer code is realized, thereby improving development efficiency.
[0018] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0020] Figure 1A flowchart of a method for generating an HTTP instance provided in Embodiment 1 of the present invention;
[0021] Figure 2 A flowchart of a method for generating an HTTP instance provided in Embodiment 2 of the present invention;
[0022] Figure 3 A schematic diagram of a flow chart of a project usage example generation module provided in the second embodiment of the present invention;
[0023] Figure 4 A schematic diagram of the structure of an HTTP instance generation device provided in Embodiment 3 of the present invention;
[0024] Figure 5 A schematic diagram of the structure of an electronic device that can be used to implement an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0026] It should be noted that the term "target" and the like in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0027] Embodiment 1
[0028] Figure 1 This is a flowchart of a method for generating an HTTP instance provided in Embodiment 1 of the present invention. This embodiment is applicable to the case where HTTP instances are generated in multiple ways. The method can be executed by an HTTP instance generating device. The HTTP instance generating device can be implemented in the form of hardware and / or software. The HTTP instance generating device can be configured in an electronic device. The electronic device can include but is not limited to a computer or a server. Figure 1As shown, the method includes:
[0029] Step 110: Generate an HTTP request sending encapsulation class based on the network request library, and create a request and response logic processing encapsulation class.
[0030] Among them, the network request library can be a tool that facilitates developers to handle HTTP network interactions. Exemplarily, the network request library may include axios. The HTTP request sending encapsulation class may be an encapsulation class responsible for the underlying HTTP request sending, which is not mixed with any business code and is only responsible for the sending of requests. Exemplarily, the HTTP request sending encapsulation class may be an encapsulation class axiosUtils. The request and response logic processing encapsulation class may be an encapsulation class responsible for request and response logic processing. The processing logic of the request and response logic processing encapsulation class revolves around the request itself and is completely unrelated to business requirements. Exemplarily, the request and response logic processing encapsulation class may be an encapsulation class HTTPUtils (HTTP request tool class).
[0031] In an embodiment of the present invention, the request methods required in the network request library can be combined and encapsulated to obtain an HTTP request sending encapsulation class, and a request and response logic processing encapsulation class can be created based on the method corresponding to the business processing logic required by the business processing.
[0032] It should be noted that the request methods in the network request library and the methods corresponding to the business processing logic are editable code segments.
[0033] Step 120: According to the target service address or pre-configured proxy association data, the instance generation module calls the request and response logic processing encapsulation class to generate a target HTTP instance.
[0034] The target service address may be the complete service address with the HTTP prefix passed in when the business code calls the instance generation module. The preconfigured proxy-related data may be data related to the configured proxy. The instance generation module may be used to generate HTTP instances, which may be understood as an encapsulation class for generating HTTP instances, equivalent to an HTTP instance factory. The HTTP instance may be understood as the specific application process of the HTTP protocol. The target HTTP instance may be the HTTP instance required by the business project generated by the instance generation module.
[0035] In the embodiment of the present invention, the target service address or pre-configured proxy association data is passed to the instance generation module, and the instance generation module calls the request and response logic processing encapsulation class based on the passed-in information to generate a target HTTP instance.
[0036] Step 130: Use the HTTP request to send the encapsulation class and send the request corresponding to the target HTTP instance.
[0037] In the embodiment of the present invention, the HTTP request sending encapsulation class can be used to send the request of the target HTTP instance.
[0038] The technical solution of the embodiment of the present invention generates an HTTP request sending encapsulation class based on a network request library, and creates a request and response logic processing encapsulation class, so that according to the target service address or pre-configured proxy association data, the request and response logic processing encapsulation class is called through the instance generation module to generate a target HTTP instance, and then the HTTP request sending encapsulation class is used to send the request corresponding to the target HTTP instance. In this solution, the HTTP instance can be automatically generated by calling the request and response logic processing encapsulation class through the instance generation module, and the HTTP request sending encapsulation class is used to automatically send the request corresponding to the target HTTP instance, and the dependence of HTTP instance generation on the configuration proxy is broken, and the problem that the existing HTTP request can only be implemented based on the configuration proxy, and the confusion of the business layer and the logic layer code is not conducive to maintenance is solved. The implementation method of HTTP requests can be expanded, and the separation of the business layer and the logic layer code is realized, thereby improving development efficiency.
[0039] Embodiment 2
[0040] Figure 2 This is a flowchart of a method for generating an HTTP instance provided in Embodiment 2 of the present invention. This embodiment is specific based on the above embodiment and provides a specific optional implementation method for determining the target service address or pre-configured proxy association data before generating the target HTTP instance by calling the request and response logic processing encapsulation class through the instance generation module according to the target service address or pre-configured proxy association data. Figure 2 As shown, the method includes:
[0041] Step 210: Generate an HTTP request sending encapsulation class based on the network request library, and create a request and response logic processing encapsulation class.
[0042] In an optional embodiment of the present invention, generating an HTTP request sending encapsulation class based on a network request library may include: performing request encapsulation based on a get request method, a post request method, a custom request method, a file upload request method, and a file download request method in the network request library to obtain an HTTP request sending encapsulation class.
[0043] Among them, the get request method and the post request method are two request methods in the HTTP protocol. The data in the get request method is attached to the end of the URL (Universal Resource Locator) in the form of query parameters. The data in the post request method is in the request body and is not exposed in the URL. The custom request method can be a custom HTTP protocol request method. The file upload request method can be a method for implementing file upload. The file download request method can be a method for implementing file download. Exemplarily, the file download request method can include but is not limited to the get request file download method, the post request file download method, the get request file download method that only obtains the file stream without writing it locally, and the post request file download method that only obtains the file stream without writing it locally.
[0044] In an embodiment of the present invention, a get request method, a post request method, a custom request method, a file upload request method, and a file download request method can be obtained from a network request library, and the obtained request methods are encapsulated to obtain an HTTP request sending encapsulation class.
[0045] In an optional embodiment of the present invention, creating a request and response logic processing encapsulation class may include: obtaining a request and response processing logic method; encapsulating the request and response processing logic method to obtain a request and response logic processing encapsulation class.
[0046] The request and response processing logic method may be composed of pre-acquired request business processing logic and request response processing logic corresponding method. The request and response processing logic method may include at least one of a request header processing method, a default request interception method, a default response interception method, a default exception interception method, a custom request interception method, a custom response interception method, a file upload logic processing method, and a file download logic processing method.
[0047] In an embodiment of the present invention, a request and response processing logic method can be established based on the request business processing logic corresponding method under HTTP, and the request response processing logic corresponding method, and the request and response processing logic method can be encapsulated to obtain a request and response logic processing encapsulation class.
[0048] Step 220: When it is detected that the business code calls the instance generation module, the business code input data is obtained.
[0049] The business code may be a business project code for calling the instance generation module. The business code input data may be data input when the business code calls the instance generation module.
[0050] In the embodiment of the present invention, if it is detected that the business code calls the instance generation module, the data passed in when the business code calls the instance generation module, ie, the business code passed-in data, is obtained.
[0051] Step 230: Parse the data passed in by the business code to obtain the target service address or pre-configured proxy related data.
[0052] In the embodiment of the present invention, the target service address in the configuration file can be obtained by parsing the data passed in by the business code, or pre-configuring the proxy association data.
[0053] Step 240: According to the target service address or pre-configured proxy association data, the instance generation module calls the request and response logic processing encapsulation class to generate a target HTTP instance.
[0054] In an optional embodiment of the present invention, according to the target service address or pre-configured proxy association data, the request and response logic processing encapsulation class is called by the instance generation module to generate the target HTTP instance, which may include: based on the instance generation module, calling the request and response logic processing encapsulation class, and generating the target HTTP instance according to the target service address; or, according to the pre-configured proxy association data, determining the configuration proxy name, and according to the configuration proxy name, calling the request and response logic processing encapsulation class by the instance generation module to generate the target HTTP instance.
[0055] The configured proxy name may refer to a unique name assigned to the proxy server in the network.
[0056] In an embodiment of the present invention, the instance generation module can generate a target HTTP instance corresponding to the target service address by calling the request and response logic processing encapsulation class according to the target service address; or, the instance generation module can generate a target HTTP instance by calling the request and response logic processing encapsulation class according to the configuration proxy name.
[0057] Step 250: Use the HTTP request to send the encapsulation class and send the request corresponding to the target HTTP instance.
[0058] In an optional embodiment of the present invention, using an HTTP request to send an encapsulation class to send a request corresponding to a target HTTP instance may include: through a business end, using an HTTP request to send an encapsulation class, calling a get request method, a post request method or a custom request method, and sending a request corresponding to a target HTTP instance.
[0059] Among them, the business end can be the configuration end of the business code.
[0060] In the embodiment of the present invention, when the service end calls the sending request method of the target HTTP instance, it uses the HTTP request sending encapsulation class to call the get request method, the post request method or the custom request method to send the request corresponding to the target HTTP instance.
[0061] In an optional embodiment of the present invention, the HTTP instance generation method may also include: including a default exception interception method in the request and response processing logic method, and when an error occurs in the request sending process corresponding to the target HTTP instance, collecting request sending error return information based on the default exception interception method; and reporting and feeding back the request sending error return information.
[0062] The request sending error return information may be data generated when an execution error occurs during the request sending process.
[0063] In an embodiment of the present invention, a default exception interception method is included in the request and response processing logic method, and when an error occurs in the request sending process corresponding to the target HTTP instance, the default exception interception method can be automatically executed to determine whether it is an execution exception or an execution interruption based on the default exception interception method, and report the feedback request to the business end to send error return information.
[0064] Figure 3 The following is a flow chart of a project usage example generation module provided in the second embodiment of the present invention. Figure 3 As shown, the instance generation module is called in the business code, and different target HTTP instances are obtained based on the different service addresses passed in. When passing in the service address, it can be the target service address (the complete service address with the HTTP prefix) or the configured proxy name (that is, the configured proxy name). Call the send request method of the target HTTP instance where the business needs it to send the request. In this solution, HTTP request sending can be implemented by configuring the proxy or using the configuration file, and the business layer and logic layer codes are separated. Project developers only need to focus on the business layer, which is convenient for operation and maintenance deployment. There are two ways to send HTTP requests during deployment, and developers only need to focus on the business, thereby improving development efficiency.
[0065] The business end can select one of the get request method, post request method and custom request method to send the request. The get request method and post request method will call the custom request method internally. The execution logic of the custom request method is as follows: First, the default request interception method will be called to determine whether the custom request interception is passed in when the target HTTP instance is created. If there is a custom request interception, the passed custom request interception method will be called (the custom request interception method is written by the developer). If the custom request interception method is not passed in when the target HTTP instance is created, the request address, request header request parameters will be assembled and returned based on the default request interception method. Specifically, if it is a get request, the parameters will be spliced after the request address, and the relevant methods of the HTTP request sending encapsulation class will be called to send the request, and then the default response interception method will be called. The default response interception method will determine whether the custom response interception is passed in when the target HTTP instance is created. If there is a custom response interception, the passed custom response interception method will be called (the custom response interception method is written by the developer). If no custom response interception is passed in when creating the target HTTP instance, the response data is initially parsed based on the default response interception method and returned to the business end. If any of the above steps fails, the default exception interception method will be executed to determine whether it is an execution exception or an execution interruption, and different request error return information will be returned to the business end.
[0066] The technical solution of the embodiment of the present invention generates an HTTP request sending encapsulation class based on a network request library, and creates a request and response logic processing encapsulation class, so that according to the target service address or pre-configured proxy association data, the request and response logic processing encapsulation class is called through the instance generation module to generate a target HTTP instance, and then the HTTP request sending encapsulation class is used to send the request corresponding to the target HTTP instance. In this solution, the HTTP instance can be automatically generated by calling the request and response logic processing encapsulation class through the instance generation module, and the HTTP request sending encapsulation class is used to automatically send the request corresponding to the target HTTP instance, and the dependence of HTTP instance generation on the configuration proxy is broken, and the problem that the existing HTTP request can only be implemented based on the configuration proxy, and the confusion of the business layer and the logic layer code is not conducive to maintenance is solved. The implementation method of HTTP requests can be expanded, and the separation of the business layer and the logic layer code is realized, thereby improving development efficiency.
[0067] Embodiment 3
[0068] Figure 4 This is a schematic diagram of the structure of an HTTP instance generation device provided by Embodiment 3 of the present invention. Figure 4 As shown, the device comprises:
[0069] The encapsulation class creation module 310 is used to generate a hypertext transfer protocol HTTP request sending encapsulation class based on the network request library, and create a request and response logic processing encapsulation class;
[0070] HTTP instance generation module 320, used to generate a target HTTP instance by calling the request and response logic processing encapsulation class through the instance generation module according to the target service address or pre-configured proxy association data;
[0071] The request sending module 330 is used to send a request corresponding to a target HTTP instance by using an HTTP request sending encapsulation class.
[0072] The technical solution of the embodiment of the present invention generates an HTTP request sending encapsulation class based on a network request library, and creates a request and response logic processing encapsulation class, so that according to the target service address or pre-configured proxy association data, the request and response logic processing encapsulation class is called through the instance generation module to generate a target HTTP instance, and then the HTTP request sending encapsulation class is used to send the request corresponding to the target HTTP instance. In this solution, the HTTP instance can be automatically generated by calling the request and response logic processing encapsulation class through the instance generation module, and the HTTP request sending encapsulation class is used to automatically send the request corresponding to the target HTTP instance, and the dependence of HTTP instance generation on the configuration proxy is broken, and the problem that the existing HTTP request can only be implemented based on the configuration proxy, and the confusion of the business layer and the logic layer code is not conducive to maintenance is solved. The implementation method of HTTP requests can be expanded, and the separation of the business layer and the logic layer code is realized, thereby improving development efficiency.
[0073] Optionally, the encapsulation class creation module 310 is specifically used to perform request encapsulation based on the get request method, post request method, custom request method, file upload request method and file download request method in the network request library to obtain the HTTP request sending encapsulation class.
[0074] Optionally, an encapsulation class creation module 310 is specifically used to obtain request and response processing logic methods; wherein the request and response processing logic methods include at least one of a request header processing method, a default request interception method, a default response interception method, a default exception interception method, a custom request interception method, a custom response interception method, a file upload logic processing method, and a file download logic processing method; encapsulate the request and response processing logic method to obtain the request and response logic processing encapsulation class.
[0075] Optionally, the HTTP instance generation device also includes an incoming data parsing module, which is used to obtain business code incoming data when it is detected that the business code calls the instance generation module; parse the business code incoming data to obtain the target service address or the pre-configured proxy association data.
[0076] Optionally, the HTTP instance generation module 320 is specifically used to call the request and response logic processing encapsulation class based on the instance generation module, and generate the target HTTP instance according to the target service address; or, determine the configuration proxy name according to the pre-configured proxy association data, and call the request and response logic processing encapsulation class through the instance generation module according to the configuration proxy name to generate the target HTTP instance.
[0077] Optionally, the request sending module 330 is specifically used to use the HTTP request sending encapsulation class through the business end to call the get request method, the post request method or the custom request method to send the request corresponding to the target HTTP instance.
[0078] Optionally, the HTTP instance generation device also includes an information reporting module, which is used to include the default exception interception method in the request and response processing logic method, and when an error occurs in the request sending process corresponding to the target HTTP instance, collect request sending error return information based on the default exception interception method; and report and feedback the request sending error return information.
[0079] The HTTP instance generation device provided in the embodiment of the present invention can execute the HTTP instance generation method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0080] Embodiment 4
[0081] Figure 5 A schematic diagram of an electronic device that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0082] like Figure 5As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0083] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0084] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the HTTP instance generation method.
[0085] In some embodiments, the HTTP instance generation method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the HTTP instance generation method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the HTTP instance generation method in any other appropriate manner (e.g., by means of firmware).
[0086] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0087] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0088] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0089] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0090] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0091] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of traditional physical hosts and VPS servers, which are difficult to manage and have weak business scalability.
[0092] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0093] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for generating an HTTP instance, characterized in that: include: Based on the network request library, generate the Hypertext Transfer Protocol HTTP request sending encapsulation class, and create the request and response logic processing encapsulation class; According to the target service address or pre-configured proxy association data, the request and response logic processing encapsulation class is called through the instance generation module to generate a target HTTP instance; The HTTP request is sent using the encapsulation class to send a request corresponding to the target HTTP instance.
2. The method according to claim 1, characterized in that Generate HTTP request sending encapsulation class based on network request library, including: Based on the get request method, post request method, custom request method, file upload request method and file download request method in the network request library, request encapsulation is performed to obtain the HTTP request sending encapsulation class.
3. The method according to claim 1, characterized in that Create a request and response logic processing encapsulation class, including: Obtain a request and response processing logic method; wherein the request and response processing logic method includes at least one of a request header processing method, a default request interception method, a default response interception method, a default exception interception method, a custom request interception method, a custom response interception method, a file upload logic processing method, and a file download logic processing method; Encapsulate the request and response processing logic method to obtain the request and response logic processing encapsulation class.
4. The method according to claim 1, characterized in that: Before calling the request and response logic processing encapsulation class through the instance generation module according to the target service address or the pre-configured proxy association data to generate the target HTTP instance, it also includes: When it is detected that the business code calls the instance generation module, the business code input data is obtained; Parse the data passed in by the business code to obtain the target service address or the pre-configured proxy associated data.
5. The method according to claim 1, characterized in that According to the target service address or pre-configured proxy association data, the request and response logic processing encapsulation class is called through the instance generation module to generate a target HTTP instance, including: Based on the instance generation module, the request and response logic processing encapsulation class is called, and the target HTTP instance is generated according to the target service address; or, According to the pre-configured proxy association data, a configuration proxy name is determined, and according to the configuration proxy name, the request and response logic processing encapsulation class is called through an instance generation module to generate a target HTTP instance.
6. The method according to claim 2, characterized in that Using the HTTP request sending encapsulation class to send a request corresponding to the target HTTP instance includes: Through the business end, the HTTP request is sent using the encapsulation class, the get request method, the post request method or the custom request method is called, and the request corresponding to the target HTTP instance is sent.
7. The method according to claim 3, characterized in that Also includes: The default exception interception method is included in the request and response processing logic method, and when an error occurs in the request sending process corresponding to the target HTTP instance, request sending error return information is collected based on the default exception interception method; The request is sent with error return information for reporting and feedback.
8. An HTTP instance generation device, characterized in that: include: The encapsulation class creation module is used to generate a hypertext transfer protocol HTTP request sending encapsulation class based on the network request library, and create a request and response logic processing encapsulation class; An HTTP instance generation module is used to generate a target HTTP instance by calling the request and response logic processing encapsulation class through the instance generation module according to the target service address or the pre-configured proxy association data; The request sending module is used to send the request corresponding to the target HTTP instance by using the HTTP request sending encapsulation class.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the HTTP instance generation method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the HTTP instance generation method according to any one of claims 1 to 7 when executed.