An extended function implementation method and device, computer device and storage medium
Patent Information
- Application Number
- CN202211517541.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-29
- Publication Date
- 2026-09-29
- Estimated Expiration
- 2042-11-29
AI Technical Summary
[0005]本申请实施例的目的在于提出一种基于路由劫持的扩展功能实现方法、装置、计算机设备及存储介质,以解决传统的扩展功能管理方法存在大量代码冗余,且出错率极高的问题
[0015]本申请提供了一种基于路由劫持的扩展功能实现方法,应用于标准子系统,其中,所述标准子系统定义了基础功能的实现,所述方法包括:接收开放子系统上报的与所述基础功能相对应的扩展功能路由信息,其中,所述开放子系统定义了扩展功能的实现方法,所述扩展功能路由信息包括劫持类型、路由方法、被劫持对象以及劫持对象;根据所述扩展功能路由信息构建路由映射表;创建中间处理器,并将所述中间处理器存储于根路由位置,当接收到用户终端发送的功能访问请求时,对所述功能访问请求进行路由劫持操作。与现有技术相比,本申请将系统拆分为标准子系统和开放子系统,标准子系统支持路由列表,开放子系统则动态实现扩展,使得代码变的清晰,减少耦合性,也让代码更加易于开发和维护。
Smart Images

Figure CN115756900B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of front-end development technology, and in particular to a method, apparatus, computer device and storage medium for implementing extended functions based on route hijacking. Background Technology
[0002] With the rapid development and changes in system research and development, systems that traditionally only have one or a few basic functions A are gradually needing to implement a large number of extended functions A2, A3... (hereinafter referred to as A*) on top of the basic functions. These extended functions are the same as those in the system, but their implementations differ. However, with the continuous increase in extended functions, the management of URLs (Uniform Resource Locators) is becoming increasingly difficult.
[0003] One existing method for managing extended functionality distinguishes features by using different URLs (Uniform Resource Locators). Different implementations of the same feature, such as A*, can be analogized to "different features" and therefore can also be distinguished using different URLs. For example, if the original URL (Uniform Resource Locator) is xxx / A, then the implementation URL (Uniform Resource Locator) of A* can be defined as xxx / A*.
[0004] However, the applicant found that the traditional extension management method requires implementing a URL for each extension separately, resulting in a large amount of redundant code and thus an increased error rate. It is evident that the traditional extension management method has a large amount of code redundancy and an extremely high error rate. Summary of the Invention
[0005] The purpose of this application is to propose a method, apparatus, computer device, and storage medium for implementing extended functions based on route hijacking, so as to solve the problems of large amount of code redundancy and extremely high error rate in traditional extended function management methods.
[0006] To address the aforementioned technical problems, this application provides a method for implementing extended functionality based on route hijacking, employing the following technical solution: This is applied to a standard subsystem, wherein the standard subsystem defines a method for implementing basic functions, the method comprising the following steps: The system receives extended function routing information corresponding to the basic function reported by the open subsystem. The open subsystem defines the implementation method of the extended function, and the extended function routing information includes hijacking type, routing method, hijacked object, and hijacking object. Construct a routing mapping table based on the extended function routing information; An intermediate processor is created and stored in the root route location. When a function access request is received from a user terminal, a route hijacking operation is performed on the function access request.
[0007] Furthermore, the hijacking types include pre-hijacking, replacement hijacking, and post-hijacking types. The step of constructing a routing mapping table based on the extended function routing information specifically includes the following steps: Create a pre-mapping table, replace a pre-mapping table, and create a post-mapping table; The extended function routing information with the hijacking type of the aforementioned pre-hijacking type is stored in the pre-hijacking mapping table; The extended function routing information with the hijacking type of the replacement hijacking type is stored in the replacement mapping table; Extended function routing information with hijacking type of the post-hijacking type is stored in the post-mapping table.
[0008] Furthermore, the intermediate processor includes a front-end processor, and after the steps of creating the intermediate processor and storing the intermediate processor in the root route location, the following steps are also included: Receive the function access request sent by the user terminal; If the routing mapping table contains front-end extended function routing information corresponding to the function access request and whose hijacking type is front-end hijacking, then the front-end processor is invoked to perform front-end hijacking operation on the front-end extended function routing information to obtain the first routing information. Based on the interface information of the first routing information, the open subsystem is notified to process the function access request and obtain the function response content; The function response content is output to the user terminal.
[0009] Furthermore, the intermediate processor also includes a replacement processor, which, after the step of calling the front processor to perform a front-end hijacking operation on the front-end extended function routing information to obtain first routing information, and before the step of notifying the open subsystem to process the function access request based on the interface information of the first routing information to obtain the function response content, further includes the following steps: If the routing mapping table contains replacement extended function routing information corresponding to the function access request and the hijacking type is replacement hijacking, then the replacement processor is invoked to perform a replacement hijacking operation on the replacement extended function routing information to obtain the second routing information; The step of notifying the open subsystem to process the function access request based on the interface information of the first routing information and obtaining the function response content specifically includes: The open subsystem is notified to process the function access request based on the interface information of the second routing information, and the function response content is obtained.
[0010] Furthermore, the step of invoking the replacement processor to perform a replacement hijacking operation on the replacement extended function routing information to obtain the second routing information specifically includes the following steps: Add header information to the interface header of the replacement extended function routing information to obtain the second routing information.
[0011] Furthermore, the intermediate processor also includes a post-processor. After the step of notifying the open subsystem to process the function access request based on the interface information of the first routing information and obtaining the function response content, and before the step of outputting the function response content to the user terminal, the method further includes the following steps: If the routing mapping table contains a post-extended function routing information corresponding to the function access request and whose hijacking type is post-hijacking, then the post-processor is invoked to perform a post-hijacking operation on the post-extended function routing information to obtain the third routing information. The step of outputting the function response content to the user terminal specifically includes: The third routing information is output to the user terminal.
[0012] To address the aforementioned technical problems, this application also provides an extended functionality implementation device based on route hijacking, employing the following technical solution: The information receiving module is used to receive extended function routing information corresponding to the basic function reported by the open subsystem. The open subsystem defines the implementation method of the extended function, and the extended function routing information includes hijacking type, routing method, hijacked object, and hijacking object. A mapping table construction module is used to construct a routing mapping table based on the extended function routing information. The processor creation module is used to create an intermediate processor and store the intermediate processor in the root route location. When a function access request sent by a user terminal is received, the module performs a route hijacking operation on the function access request.
[0013] To address the aforementioned technical problems, this application also provides a computer device that employs the following technical solution: It includes a memory and a processor, wherein the memory stores computer-readable instructions, and the processor executes the computer-readable instructions to implement the steps of the extended function implementation method based on route hijacking as described above.
[0014] To address the aforementioned technical problems, this application also provides a computer-readable storage medium, employing the technical solution described below: The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the extended functionality implementation method based on route hijacking as described above.
[0015] This application provides a method for implementing extended functions based on route hijacking, applied to a standard subsystem. The standard subsystem defines the implementation of basic functions. The method includes: receiving extended function routing information corresponding to the basic functions reported by an open subsystem, wherein the open subsystem defines the implementation method of the extended functions, and the extended function routing information includes hijacking type, routing method, hijacked object, and hijacking object; constructing a routing mapping table based on the extended function routing information; creating an intermediate processor and storing the intermediate processor at the root route location; and performing route hijacking operation on the function access request sent by a user terminal when a function access request is received. Compared with existing technologies, this application splits the system into a standard subsystem and an open subsystem. The standard subsystem supports routing lists, while the open subsystem dynamically implements extensions, making the code clearer, reducing coupling, and making the code easier to develop and maintain. Attached Figure Description
[0016] To more clearly illustrate the solutions in this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is an exemplary system architecture diagram to which this application can be applied; Figure 2 This is a flowchart illustrating the implementation of the extended functionality based on route hijacking provided in Embodiment 1 of this application. Figure 3 yes Figure 2 A flowchart of a specific implementation of step S202; Figure 4 yes Figure 2 A flowchart of a specific implementation method following step S203; Figure 5 yes Figure 4 A flowchart of a specific implementation of step S402 and step S403; Figure 6 yes Figure 4A flowchart of a specific implementation method after step S403 and before step S404; Figure 7 This is a schematic diagram of the extended function implementation device based on route hijacking provided in Embodiment 2 of this application; Figure 8 This is a schematic diagram of the structure of one embodiment of the computer device according to this application. Detailed Implementation
[0018] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein in the specification of the application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "comprising" and "having," and any variations thereof, in the specification, claims, and foregoing drawings of this application, are intended to cover non-exclusive inclusion. The terms "first," "second," etc., in the specification, claims, or foregoing drawings of this application are used to distinguish different objects, not to describe a particular order.
[0019] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0020] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
[0021] like Figure 1 As shown, system architecture 100 may include terminal devices 101, 102, and 103, a network 104, and a server 105. Network 104 serves as the medium for providing communication links between terminal devices 101, 102, and 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0022] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social media platform software, etc.
[0023] Terminal devices 101, 102, and 103 can be various electronic devices with displays and support web browsing, including but not limited to smartphones, tablets, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 players (Moving Picture Experts Group Audio Layer IV), laptops, and desktop computers, etc.
[0024] Server 105 can be a server that provides various services, such as a backend server that supports the pages displayed on terminal devices 101, 102, and 103.
[0025] It should be noted that the extended function implementation method based on route hijacking provided in this application embodiment is generally executed by a server / terminal device, and correspondingly, the extended function implementation device based on route hijacking is generally set in the server / terminal device.
[0026] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0027] Example 1 Continue to refer to Figure 2 The diagram shows the implementation flowchart of the extended function implementation method based on route hijacking provided in Embodiment 1 of this application. For ease of explanation, only the parts related to this application are shown.
[0028] The above-described method for implementing extended functionality based on route hijacking is applied to a standard subsystem. The standard subsystem defines the implementation method for basic functionality, which includes the following steps: In step S201, the extended function routing information corresponding to the basic function reported by the open subsystem is received. The open subsystem defines the implementation method of the extended function, and the extended function routing information includes the hijacking type, routing method, hijacked object, and hijacking object.
[0029] In the embodiments of this application, the standard subsystem predefines several basic functions (A) and their implementation methods. These basic functions (A) can be implemented in the standard subsystem, while the open subsystem is used to define several extended functions A2, A3...An (extended functions are uniformly represented as A*) based on these basic functions (A). The extended functions (A*) are mainly implemented in the open subsystem.
[0030] In this embodiment of the application, the open subsystem includes a method for implementing extended functionality (A*). The open subsystem reports the implemented A* routing information to the standard subsystem, thereby realizing dynamic injection of routes into the standard subsystem.
[0031] In this embodiment, the open subsystem periodically reports its implemented A* routing information. The key fields of the reported information are defined as: {type, method, url, function}. The field type represents the hijacking type, with values ranging from [replace, prefix, suffix]; the field method is the routing method, an array type, with possible values [GET, POST]; the field url is the routing URL defined by the standard subsystem, i.e., the hijacked object; and the field function is the implementation by the open subsystem, i.e., the object that hijacks the routing URL defined by the standard subsystem.
[0032] In step S202, a routing mapping table is constructed based on the extended function routing information.
[0033] In this embodiment of the application, the standard subsystem constructs a Map mapping table based on the reported A* routing information.
[0034] In step S203, an intermediate processor is created and stored in the root route location. When a function access request sent by a user terminal is received, a route hijacking operation is performed on the function access request.
[0035] In this embodiment of the application, the standard subsystem defines and implements middleware logic. The middleware is added to the root route (i.e., https: / / xxxx / ) and filters and intercepts each URL (Uniform Resource Locator) request according to the constructed Map mapping table.
[0036] In some optimized embodiments of this application, the open subsystem not only reports routing information to the standard subsystem at startup, but also periodically (every 3 seconds). When the routing information of the open subsystem is modified, the standard subsystem can obtain the new routing information in real time, i.e., dynamic injection.
[0037] This application provides a method for implementing extended functions based on route hijacking, applied to a standard subsystem. The standard subsystem defines the implementation method for basic functions. The method includes the following steps: receiving extended function routing information corresponding to the basic functions reported by an open subsystem. The open subsystem defines the implementation method for the extended functions, and the extended function routing information includes hijacking type, routing method, hijacked object, and hijacking object; constructing a routing mapping table based on the extended function routing information; creating an intermediate processor and storing it at the root route location; and performing route hijacking on the function access request when a function access request is received from a user terminal. Compared with existing technologies, this application splits the system into a standard subsystem and an open subsystem. The standard subsystem supports routing lists, while the open subsystem dynamically implements extensions, making the code clearer, reducing coupling, and making the code easier to develop and maintain.
[0038] Continue reading Figure 3 , showed Figure 2 The flowchart of a specific implementation of step S202 is shown. For ease of explanation, only the parts relevant to this application are shown.
[0039] In some optional implementations of this embodiment, step S202 specifically includes: step S301, step S302, step S303 and step S304.
[0040] In step S301, a pre-mapping table, a replacement mapping table, and a post-mapping table are created; In step S302, the extended function routing information with the hijacking type of pre-hijacking is stored in the pre-mapping mapping table; In step S303, the extended function routing information with hijacking type of replacement hijacking is stored in the replacement mapping table; In step S304, the extended function routing information of the hijacking type of post-hijacking is stored in the post-mapping table.
[0041] In this embodiment, to maximize query routing efficiency, A* is stored in three Map tables according to the hijacking method: prefixMap, replaceMap, and suffixMap. Each Map table uses the combination of path and method from the URL as the key and the reported routing information as the value.
[0042] Continue reading Figure 4 , showed Figure 2 The flowchart of a specific implementation after step S203 is shown. For ease of explanation, only the parts relevant to this application are shown.
[0043] In some optional implementations of this embodiment, after step S203, the method further includes steps S401, S402, S403, and S404.
[0044] In step S401, a function access request sent by a user terminal is received; In step S402, if there is a front-end extended function routing information in the routing mapping table that corresponds to the function access request and whose hijacking type is front-end hijacking, then the front-end processor is called to perform a front-end hijacking operation on the front-end extended function routing information to obtain the first routing information. In step S403, the open subsystem is notified to process the function access request based on the interface information of the first routing information, and the function response content is obtained; In step S404, the function response content is output to the user terminal.
[0045] In the embodiments of this application, pre-hijacking is generally used to modify the parameters of a request or to check whether the request meets specific conditions. When an A* request enters the standard subsystem, it is forwarded to the open subsystem before being processed. The open subsystem modifies the request and then sends it back to the standard subsystem for continued execution.
[0046] Continue reading Figure 5 , showed Figure 4 The flowchart shows a specific implementation of step S402 and step S403. For ease of explanation, only the parts relevant to this application are shown.
[0047] In some optional implementations of this embodiment, after step S402, step S501 is further included, and step S403 specifically includes step S502.
[0048] In step S501, if there is replacement extended function routing information corresponding to the function access request in the routing mapping table and the hijacking type is replacement hijacking, then the replacement processor is called to perform a replacement hijacking operation on the replacement extended function routing information to obtain the second routing information. In step S502, the open subsystem is notified to process the function access request based on the interface information of the second routing information, and the function response content is obtained.
[0049] In this embodiment of the application, "replacement" means directly replacing a certain interface of the standard subsystem, and the A* request will be handled by the open subsystem with a completely customized implementation.
[0050] In this embodiment of the application, when a user's access request reaches the standard subsystem, it will be processed by a pre-processing, replacement, or post-processing middleware. At this time, the request will hit the Map mapping table in the replacement middleware.
[0051] In some optional implementations of this embodiment, step S501 specifically includes: adding header information to the interface header that replaces the extended function routing information to obtain the second routing information.
[0052] In this embodiment of the application, the standard subsystem notifies the open subsystem to execute the corresponding interface based on the information in the Map mapping table, and the latter returns the processing result to the standard subsystem.
[0053] In practical applications, for example, consider replacing the route for retrieving user information. Suppose the standard subsystem defines a route that retrieves user information via " / users / me" using the GET method, and the open subsystem later implements a new method for retrieving user information, `me_new`. Then, the routing information reported by the open subsystem to the standard subsystem could be: `{type:replace,method:[GET],url: / users / me,function:me_new}`. When a user accesses the service, we only need to add the header information `headers: { 'Replace': "replace"}` to the ` / users / me` interface header to indicate that the open subsystem implementation is being used.
[0054] Continue reading Figure 6 , showed Figure 4 The flowchart shows a specific implementation after step S403 and before step S404. For ease of explanation, only the parts relevant to this application are shown.
[0055] In some optional implementations of this embodiment, after step S403 and before step S404, step S601 is further included, and step S404 specifically includes step S602.
[0056] In step S601, if there is a post-extended function routing information in the routing mapping table that corresponds to the function access request and whose hijacking type is post-hijacking, then the post-processor is called to perform a post-hijacking operation on the post-extended function routing information to obtain the third routing information. In step S602, third routing information is output to the user terminal.
[0057] In the embodiments of this application, post-hijacking is generally used to process the response content. For example, the standard subsystem defines two POST method routes: " / requirement / updateState" and "task / updateState", the former being the requirement status and the latter the task status.
[0058] In this embodiment, after fulfilling the requirements, it is also necessary to update the task status. We can achieve this using a post-hijacking approach, opening the information reported by the subsystem: {type:suffix,method:[POST],url: / requirement / updateState,function:task / updateState}.
[0059] In this embodiment of the application, after the A* request is processed in the standard subsystem, it will be passed to the open subsystem, which will modify its content and then pass it back to the standard subsystem, and then return it to the requester.
[0060] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing related hardware through computer-readable instructions. These computer-readable instructions can be stored in a computer-readable storage medium. When executed, the computer-readable instructions can include the processes of the embodiments of the above methods. The aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, optical disk, or read-only memory (ROM), or random access memory (RAM).
[0061] It should be understood that although the steps in the flowcharts of the accompanying figures are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the accompanying figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0062] Example 2 Further reference Figure 7 As a response to the above Figure 2 To implement the method shown, this application provides an embodiment of an extended functionality implementation device based on route hijacking. This device embodiment is similar to... Figure 2 Corresponding to the method embodiments shown, this device can be specifically applied to various electronic devices.
[0063] like Figure 7 As shown, the extended function implementation device 200 based on route hijacking in this embodiment includes: an information receiving module 210, a mapping table construction module 220, and a processor creation module 230. Wherein: The information receiving module 210 is used to receive the extended function routing information corresponding to the basic function reported by the open subsystem. The open subsystem defines the implementation method of the extended function, and the extended function routing information includes the hijacking type, routing method, hijacked object, and hijacking object. The mapping table construction module 220 is used to construct a routing mapping table based on the extended function routing information; The processor creation module 230 is used to create an intermediate processor and store the intermediate processor in the root route location. When a function access request sent by a user terminal is received, the function access request is route hijacked.
[0064] In the embodiments of this application, the standard subsystem predefines several basic functions (A) and their implementation methods. These basic functions (A) can be implemented in the standard subsystem, while the open subsystem is used to define several extended functions A2, A3...An (extended functions are uniformly represented as A*) based on these basic functions (A). The extended functions (A*) are mainly implemented in the open subsystem.
[0065] In this embodiment of the application, the extended function implementation device 200 based on route hijacking is applied to a standard subsystem, wherein the standard subsystem defines the implementation method of the basic function.
[0066] In this embodiment of the application, the open subsystem includes a method for implementing extended functionality (A*). The open subsystem reports the implemented A* routing information to the standard subsystem, thereby realizing dynamic injection of routes into the standard subsystem.
[0067] In this embodiment, the open subsystem periodically reports its implemented A* routing information. The key fields of the reported information are defined as: {type, method, url, function}. The field type represents the hijacking type, with values ranging from [replace, prefix, suffix]; the field method is the routing method, an array type, with possible values [GET, POST]; the field url is the routing URL defined by the standard subsystem, i.e., the hijacked object; and the field function is the implementation by the open subsystem, i.e., the object that hijacks the routing URL defined by the standard subsystem.
[0068] In this embodiment of the application, the standard subsystem constructs a Map mapping table based on the reported A* routing information.
[0069] In this embodiment of the application, the standard subsystem defines and implements middleware logic. The middleware is added to the root route (i.e., https: / / xxxx / ) and filters and intercepts each URL (Uniform Resource Locator) request according to the constructed Map mapping table.
[0070] In some optimized embodiments of this application, the open subsystem not only reports routing information to the standard subsystem at startup, but also periodically (every 3 seconds). When the routing information of the open subsystem is modified, the standard subsystem can obtain the new routing information in real time, i.e., dynamic injection.
[0071] In this embodiment, a route hijacking-based extended function implementation device 200 is provided, applied to a standard subsystem. The standard subsystem defines the implementation method of basic functions. The device 200 includes: an information receiving module 210, used to receive extended function routing information corresponding to the basic functions reported by an open subsystem. The open subsystem defines the implementation method of the extended functions, and the extended function routing information includes hijacking type, routing method, hijacked object, and hijacking object; a mapping table construction module 220, used to construct a routing mapping table based on the extended function routing information; and a processor creation module 230, used to create an intermediate processor and store it at the root route location. When a function access request sent by a user terminal is received, a route hijacking operation is performed on the function access request. Compared with the prior art, this application splits the system into a standard subsystem and an open subsystem. The standard subsystem supports routing lists, while the open subsystem dynamically implements extensions, making the code clearer, reducing coupling, and making the code easier to develop and maintain.
[0072] In some optional implementations of this embodiment, the hijacking types include pre-hijacking, replacement hijacking, and post-hijacking. The mapping table construction module 220 includes a creation submodule, a pre-storage submodule, a replacement storage submodule, and a post-storage submodule, wherein: Create submodules for creating pre-mapping tables, replacement tables, and post-mapping tables; The front-end storage submodule is used to store extended function routing information of the front-end hijacking type in the front-end mapping table; The replacement storage submodule is used to store extended function routing information of the replacement hijacking type in the replacement mapping table; The back-end storage submodule is used to store extended function routing information of the back-end hijacking type in the back-end mapping table.
[0073] In this embodiment, to maximize query routing efficiency, A* is stored in three Map tables according to the hijacking method: prefixMap, replaceMap, and suffixMap. Each Map table uses the combination of path and method from the URL as the key and the reported routing information as the value.
[0074] In some optional implementations of this embodiment, the intermediate processor includes a preprocessor, and the above-mentioned extended function implementation device 200 based on route hijacking further includes: a request receiving module, a pre-hijacking module, a request processing module, and an output module, wherein: The request receiving module is used to receive function access requests sent by user terminals. The pre-hijacking module is used to call the pre-processor to perform a pre-hijacking operation on the pre-extended function routing information if there is a pre-hijacking type corresponding to the function access request in the routing mapping table. The request processing module is used to notify the open subsystem to process the function access request based on the interface information of the first routing information and to obtain the function response content. The output module is used to output the function response content to the user terminal.
[0075] In the embodiments of this application, pre-hijacking is generally used to modify the parameters of a request or to check whether the request meets specific conditions. When an A* request enters the standard subsystem, it is forwarded to the open subsystem before being processed. The open subsystem modifies the request and then sends it back to the standard subsystem for continued execution.
[0076] In some optional implementations of this embodiment, the intermediate processor further includes a replacement processor, and the above-mentioned extended function implementation device 200 based on route hijacking further includes: a replacement hijacking module, and the above-mentioned request processing module includes: a request processing submodule, wherein: The replacement hijacking module is used to call the replacement processor to perform a replacement hijacking operation on the replacement extended function routing information if there is a corresponding function access request in the routing mapping table and the hijacking type is replacement hijacking, so as to obtain the second routing information. The request processing submodule is used to notify the open subsystem to process the function access request based on the interface information of the second routing information and obtain the function response content.
[0077] In this embodiment of the application, "replacement" means directly replacing a certain interface of the standard subsystem, and the A* request will be handled by the open subsystem with a completely customized implementation.
[0078] In this embodiment of the application, when a user's access request reaches the standard subsystem, it will be processed by a pre-processing, replacement, or post-processing middleware. At this time, the request will hit the Map mapping table in the replacement middleware.
[0079] In some optional implementations of this embodiment, the replacement hijacking module includes: a replacement hijacking submodule, wherein: The replacement hijacking submodule is used to add header information to the interface header of the replacement extended function routing information to obtain the second routing information.
[0080] In this embodiment of the application, the standard subsystem notifies the open subsystem to execute the corresponding interface based on the information in the Map mapping table, and the latter returns the processing result to the standard subsystem.
[0081] In practical applications, for example, consider replacing the route for retrieving user information. Suppose the standard subsystem defines a route that retrieves user information via " / users / me" using the GET method, and the open subsystem later implements a new method for retrieving user information, `me_new`. Then, the routing information reported by the open subsystem to the standard subsystem could be: `{type:replace,method:[GET],url: / users / me,function:me_new}`. When a user accesses the service, we only need to add the header information `headers: { 'Replace': "replace"}` to the ` / users / me` interface header to indicate that the open subsystem implementation is being used.
[0082] In some optional implementations of this embodiment, the intermediate processor further includes a post-processor, and the above-mentioned extended function implementation device 200 based on route hijacking further includes: a post-hijacking module, and the above-mentioned output module specifically includes: an output sub-module, wherein: The post-hijacking module is used to call the post-processor to perform a post-hijacking operation on the post-extended function routing information if there is a corresponding function access request in the routing mapping table and the hijacking type is post-hijacking, so as to obtain the third routing information. The output submodule is used to output third-party routing information to the user terminal.
[0083] In the embodiments of this application, post-hijacking is generally used to process the response content. For example, the standard subsystem defines two POST method routes: " / requirement / updateState" and "task / updateState", the former being the requirement status and the latter the task status.
[0084] In this embodiment, after fulfilling the requirements, it is also necessary to update the task status. We can achieve this using a post-hijacking approach, opening the information reported by the subsystem: {type:suffix,method:[POST],url: / requirement / updateState,function:task / updateState}.
[0085] In this embodiment of the application, after the A* request is processed in the standard subsystem, it will be passed to the open subsystem, which will modify its content and then pass it back to the standard subsystem, and then return it to the requester.
[0086] To address the aforementioned technical problems, embodiments of this application also provide a computer device. Please refer to [link / reference needed]. Figure 8 , Figure 8 This is a basic structural block diagram of the computer device in this embodiment.
[0087] The computer device 300 includes a memory 310, a processor 320, and a network interface 330 that are interconnected via a system bus. It should be noted that only the computer device 300 with components 310-330 is shown in the figure; however, it should be understood that it is not required to implement all the shown components, and more or fewer components can be implemented alternatively. Those skilled in the art will understand that the computer device described here is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.
[0088] The computer device can be a desktop computer, laptop, handheld computer, or cloud server, etc. The computer device can interact with the user via a keyboard, mouse, remote control, touchpad, or voice control.
[0089] The memory 310 includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 310 may be an internal storage unit of the computer device 300, such as the hard disk or memory of the computer device 300. In other embodiments, the memory 310 may also be an external storage device of the computer device 300, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc. Of course, the memory 310 may also include both internal storage units and external storage devices of the computer device 300. In this embodiment, the memory 310 is typically used to store the operating system and various application software installed on the computer device 300, such as computer-readable instructions for implementing extended functions based on route hijacking. Furthermore, the memory 310 can also be used to temporarily store various types of data that have been output or will be output.
[0090] In some embodiments, the processor 320 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 320 is typically used to control the overall operation of the computer device 300. In this embodiment, the processor 320 is used to execute computer-readable instructions stored in the memory 310 or to process data, for example, to execute computer-readable instructions of the route hijacking-based extended functionality implementation method.
[0091] The network interface 330 may include a wireless network interface or a wired network interface, which is typically used to establish communication connections between the computer device 300 and other electronic devices.
[0092] The computer device provided in this application divides the system into a standard subsystem and an open subsystem. The standard subsystem supports routing lists, while the open subsystem dynamically expands, making the code clearer, reducing coupling, and making the code easier to develop and maintain.
[0093] This application also provides another embodiment, namely, providing a computer-readable storage medium storing computer-readable instructions that can be executed by at least one processor to cause the at least one processor to perform the steps of the extended functionality implementation method based on route hijacking as described above.
[0094] The computer-readable storage medium provided in this application divides the system into a standard subsystem and an open subsystem. The standard subsystem supports routing lists, while the open subsystem dynamically implements extensions, making the code clearer, reducing coupling, and making the code easier to develop and maintain.
[0095] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0096] Obviously, the embodiments described above are only some embodiments of this application, not all embodiments. The accompanying drawings show preferred embodiments of this application, but do not limit the patent scope of this application. This application can be implemented in many different forms; rather, the purpose of providing these embodiments is to provide a more thorough and comprehensive understanding of the disclosure of this application. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing specific embodiments, or make equivalent substitutions for some of the technical features. Any equivalent structures made using the content of this application's specification and drawings, directly or indirectly applied to other related technical fields, are similarly within the scope of patent protection of this application.
Claims
1. A method for implementing extended functionality based on route hijacking, characterized in that, This is applied to a standard subsystem, wherein the standard subsystem defines a method for implementing basic functions, the method comprising the following steps: The system receives extended function routing information corresponding to the basic function reported by the open subsystem. The open subsystem defines the implementation method of the extended function, and the extended function routing information includes hijacking type, routing method, hijacked object, and hijacking object. Construct a routing mapping table based on the extended function routing information; An intermediate processor is created and stored in the root route location. When a function access request sent by a user terminal is received, a route hijacking operation is performed on the function access request. The intermediate processor includes a front-end processor, and after the steps of creating the intermediate processor and storing the intermediate processor in the root route location, the following steps are also included: Receive the function access request sent by the user terminal; If the routing mapping table contains front-end extended function routing information corresponding to the function access request and whose hijacking type is front-end hijacking, then the front-end processor is invoked to perform front-end hijacking operation on the front-end extended function routing information to obtain the first routing information. Based on the interface information of the first routing information, the open subsystem is notified to process the function access request and obtain the function response content; The function response content is output to the user terminal.
2. The method for implementing extended functions based on route hijacking according to claim 1, characterized in that, The hijacking types include pre-hijacking, replacement hijacking, and post-hijacking. The step of constructing a routing mapping table based on the extended function routing information specifically includes the following steps: Create a pre-mapping table, replace a pre-mapping table, and create a post-mapping table; The extended function routing information with the hijacking type of the aforementioned pre-hijacking type is stored in the pre-hijacking mapping table; The extended function routing information with the hijacking type of the replacement hijacking type is stored in the replacement mapping table; Extended function routing information with hijacking type of the post-hijacking type is stored in the post-mapping table.
3. The method for implementing extended functions based on route hijacking according to claim 1, characterized in that, The intermediate processor further includes a replacement processor, which, after the step of calling the front processor to perform a front-end hijacking operation on the front-end extended function routing information to obtain first routing information, and before the step of notifying the open subsystem to process the function access request based on the interface information of the first routing information to obtain the function response content, further includes the following steps: If the routing mapping table contains replacement extended function routing information corresponding to the function access request and the hijacking type is replacement hijacking, then the replacement processor is invoked to perform a replacement hijacking operation on the replacement extended function routing information to obtain the second routing information; The step of notifying the open subsystem to process the function access request based on the interface information of the first routing information and obtaining the function response content specifically includes: The open subsystem is notified to process the function access request based on the interface information of the second routing information, and the function response content is obtained.
4. The method for implementing extended functions based on route hijacking according to claim 3, characterized in that, The step of invoking the replacement processor to perform a replacement hijacking operation on the replacement extended function routing information to obtain the second routing information specifically includes the following steps: Add header information to the interface header of the replacement extended function routing information to obtain the second routing information.
5. The method for implementing extended functions based on route hijacking according to claim 1, characterized in that, The intermediate processor further includes a post-processor. After the step of notifying the open subsystem to process the function access request based on the interface information of the first routing information and obtaining the function response content, and before the step of outputting the function response content to the user terminal, the method further includes the following steps: If the routing mapping table contains a post-extended function routing information corresponding to the function access request and whose hijacking type is post-hijacking, then the post-processor is invoked to perform a post-hijacking operation on the post-extended function routing information to obtain the third routing information. The step of outputting the function response content to the user terminal specifically includes: The third routing information is output to the user terminal.
6. A device for implementing extended functions based on route hijacking, characterized in that, Applied to a standard subsystem, wherein the standard subsystem defines methods for implementing basic functions, the device includes: The information receiving module is used to receive extended function routing information corresponding to the basic function reported by the open subsystem. The open subsystem defines the implementation method of the extended function, and the extended function routing information includes hijacking type, routing method, hijacked object, and hijacking object. A mapping table construction module is used to construct a routing mapping table based on the extended function routing information. The processor creation module is used to create an intermediate processor and store the intermediate processor in the root route location. When a function access request sent by a user terminal is received, a route hijacking operation is performed on the function access request. The intermediate processor includes a preprocessor, and the device further includes: a request receiving module, a pre-hijacking module, a request processing module, and an output module, wherein: The request receiving module is used to receive the function access request sent by the user terminal; The pre-hijacking module is used to call the pre-processor to perform a pre-hijacking operation on the pre-extended function routing information if there is a pre-hijacking type of pre-extended function routing information corresponding to the function access request in the routing mapping table. This will obtain the first routing information. The request processing module is used to notify the open subsystem to process the function access request based on the interface information of the first routing information, and obtain the function response content; The output module is used to output the function response content to the user terminal.
7. The extended function implementation device based on route hijacking according to claim 6, characterized in that, The hijacking types include pre-hijacking, replacement hijacking, and post-hijacking. The mapping table construction module includes: Create submodules for creating pre-mapping tables, replacement tables, and post-mapping tables; The front-end storage submodule is used to store extended function routing information with the hijacking type of the front-end hijacking type in the front-end mapping table; The replacement storage submodule is used to store extended function routing information with the hijacking type of the replacement hijacking type in the replacement mapping table; The post-storage submodule is used to store extended function routing information of the hijacking type as the post-hijacking type in the post-mapping table.
8. A computer device, characterized in that, The method includes a memory and a processor, wherein the memory stores computer-readable instructions, and the processor executes the computer-readable instructions to implement the steps of the extended functionality implementation method based on route hijacking as described in any one of claims 1 to 5.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the extended functionality implementation method based on route hijacking as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Programming-based routing proxy hijacking method and device, and electronic equipment
CN109660519A
Front-end micro-service method and device based on dynamic routing and electronic equipment
CN114357327A