Resource access processing method, apparatus, device, storage medium, and program product
Patent Information
- Application Number
- CN202211116295.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-14
- Publication Date
- 2026-09-25
- Estimated Expiration
- 2042-09-14
AI Technical Summary
[0004]然而,传统的修改和部署方式,通常需要对在原来的项目基础上做较多改动,包括服务器段、客户端的业务代码均需要进行修改以及重新打包,耗费较多处理时间,且当存在多个客户端需要访问同一个项目的资源文件时,通常需要针对每个客户端分别维护各自的网关部署代码,进一步增加了项目的维护成本,仍然存在开发效率低下的问题
[0065]上述资源访问处理方法、装置、计算机设备、存储介质和计算机程序产品中,通过获取与接收到的资源访问请求对应的请求类型,并确定与请求类型匹配的网关标记更新处理方式,进而根据与请求类型匹配的网关标记更新方式,对资源访问请求进行网关标记更新处理,获得更新资源访问请求。进一步通过获取与更新资源访问请求匹配的数据资源,并在数据资源中添加目标网关标记,其中,目标网关标记和网关插件匹配,以得到携带目标网关标记的数据资源,并反馈携带目标网关标记的数据资源。实现了通过服务器部署的网关插件处理跨网关的资源访问请求,且基于网关插件可在资源访问处理过程中为数据资源添加目标网关标记,从而满足网关两侧的不同环境的访问规则,而无需对网关两侧的不同环境的业务代码进行全面修改、重新编译打包,可减少部署有网关的项目开发过程中的资源消耗,并进一步提升项目开发效率。
Smart Images

Figure CN117008988B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a resource access processing method, apparatus, computer equipment, storage medium, and program product. Background Technology
[0002] With the development of computer technology and the widespread application of internet applications, the performance requirements of various applications or platforms are increasing, necessitating further development and deployment of applications or platforms based on different practical needs. In some project development scenarios, it's necessary to deploy the developed project to the client's network environment while simultaneously supporting local access. However, due to development environment requirements or project limitations, it's necessary to isolate the client's network environment from the server's to avoid the risk of server resource leakage. Further, a gateway is deployed to connect the two isolated network environments, allowing the client to access the server through the gateway and obtain server resources for subsequent processing such as project development and feature deployment.
[0003] In traditional technologies, for network environments where gateways are deployed on clients and servers, the usual approach is to modify and adapt the business code on both the server and client sides separately, repackage the modified business code, and then deploy them separately, so that the client can access the server's resources.
[0004] However, traditional modification and deployment methods usually require significant changes to the original project, including modifications and repackaging of the server-side and client-side business code, which consumes a lot of processing time. Furthermore, when multiple clients need to access the same project's resource files, it is usually necessary to maintain separate gateway deployment code for each client, further increasing the project's maintenance costs and still resulting in low development efficiency. Summary of the Invention
[0005] Therefore, it is necessary to provide a resource access processing method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can reduce project development resource consumption and improve project development efficiency in response to the above-mentioned technical problems.
[0006] Firstly, this application provides a resource access processing method. The method includes:
[0007] Get the request type corresponding to the received resource access request;
[0008] Determine the gateway tag update processing method that matches the request type;
[0009] Based on the gateway tag update method that matches the request type, the resource access request is processed to update the gateway tag, thereby obtaining an updated resource access request.
[0010] Obtain the data resource that matches the updated resource access request, and add the target gateway tag to the data resource to obtain the data resource carrying the target gateway tag; the target gateway tag matches the gateway plugin;
[0011] The data resources carrying the target gateway tag are fed back.
[0012] In one embodiment, the method further includes:
[0013] If a gateway configuration request is detected, obtain the gateway configuration information carried in the gateway configuration request;
[0014] The terminal is configured with a gateway plugin that matches the gateway configuration information; the gateway plugin carries a gateway prefix for cross-gateway access.
[0015] In one embodiment, the step of acquiring a data resource matching the update resource access request and adding a target gateway tag to the data resource to obtain a data resource carrying the target gateway tag includes: acquiring a file stream matching the update special scenario processing request and adding a target gateway tag to the file stream to obtain a file stream carrying the target gateway tag.
[0016] In one embodiment, before obtaining the request type corresponding to the received resource access request, the method further includes:
[0017] Receive a resource access address carrying a gateway prefix, and clear the gateway prefix to obtain a resource access address with the gateway prefix cleared;
[0018] Obtain the HTML file corresponding to the resource access address excluding the gateway prefix, and add the gateway prefix to the HTML file to obtain the HTML file with the gateway prefix added;
[0019] The HTML file with the added gateway prefix is fed back; the HTML file with the added gateway prefix is used to trigger a resource access request, and the resource access request carries the gateway prefix.
[0020] Receive the resource access request and clear the gateway prefix carried in the resource access request.
[0021] Secondly, this application also provides a resource access processing method. The method includes:
[0022] Receive and execute an HTML file, and generate a resource access request that matches the HTML file; the HTML file is obtained by the gateway plugin from the server;
[0023] A global interception operation is triggered based on the resource access request. If it is determined that the resource access request does not carry a target gateway tag that matches the gateway plugin, the target gateway tag is added to the resource access request.
[0024] The resource access request carrying the target gateway tag is forwarded to the gateway plugin deployed on the server, and the data resource carrying the target gateway tag is received back from the gateway plugin.
[0025] Thirdly, this application also provides a resource access processing apparatus. The apparatus includes:
[0026] The request type acquisition module is used to obtain the request type corresponding to the received resource access request;
[0027] The gateway tag update processing method determination module is used to determine the gateway tag update processing method that matches the request type;
[0028] The resource access request update module is used to perform gateway tag update processing on the resource access request according to the gateway tag update method that matches the request type, so as to obtain an updated resource access request.
[0029] The data resource acquisition module is used to acquire data resources that match the updated resource access request, and add a target gateway tag to the data resources to obtain data resources carrying the target gateway tag; the target gateway tag matches the gateway plugin.
[0030] The data resource feedback module is used to provide feedback on the data resources carrying the target gateway tag.
[0031] Fourthly, this application also provides a resource access processing apparatus. The apparatus includes:
[0032] The resource access request generation module is used to receive and execute an HTML file and generate a resource access request that matches the HTML file; the HTML file is obtained by the gateway plugin from the server.
[0033] The interception processing module is used to trigger a global interception operation based on the resource access request. If it is determined that the resource access request does not carry a target gateway tag that matches the gateway plugin, the target gateway tag is added to the resource access request.
[0034] The data resource receiving module is used to forward resource access requests carrying the target gateway tag to the gateway plugin deployed on the server, and to receive data resources carrying the target gateway tag from the gateway plugin.
[0035] Fifthly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0036] Get the request type corresponding to the received resource access request;
[0037] Determine the gateway tag update processing method that matches the request type;
[0038] Based on the gateway tag update method that matches the request type, the resource access request is processed to update the gateway tag, thereby obtaining an updated resource access request.
[0039] Obtain the data resource that matches the updated resource access request, and add the target gateway tag to the data resource to obtain the data resource carrying the target gateway tag; the target gateway tag matches the gateway plugin;
[0040] The data resources carrying the target gateway tag are fed back.
[0041] Sixthly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0042] Receive and execute an HTML file, and generate a resource access request that matches the HTML file; the HTML file is obtained by the gateway plugin from the server;
[0043] A global interception operation is triggered based on the resource access request. If it is determined that the resource access request does not carry a target gateway tag that matches the gateway plugin, the target gateway tag is added to the resource access request.
[0044] The resource access request carrying the target gateway tag is forwarded to the gateway plugin deployed on the server, and the data resource carrying the target gateway tag is received back from the gateway plugin.
[0045] Seventhly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0046] Get the request type corresponding to the received resource access request;
[0047] Determine the gateway tag update processing method that matches the request type;
[0048] Based on the gateway tag update method that matches the request type, the resource access request is processed to update the gateway tag, thereby obtaining an updated resource access request.
[0049] Obtain the data resource that matches the updated resource access request, and add the target gateway tag to the data resource to obtain the data resource carrying the target gateway tag; the target gateway tag matches the gateway plugin;
[0050] The data resources carrying the target gateway tag are fed back.
[0051] Eighthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0052] Receive and execute an HTML file, and generate a resource access request that matches the HTML file; the HTML file is obtained by the gateway plugin from the server;
[0053] A global interception operation is triggered based on the resource access request. If it is determined that the resource access request does not carry a target gateway tag that matches the gateway plugin, the target gateway tag is added to the resource access request.
[0054] The resource access request carrying the target gateway tag is forwarded to the gateway plugin deployed on the server, and the data resource carrying the target gateway tag is received back from the gateway plugin.
[0055] Ninthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:
[0056] Get the request type corresponding to the received resource access request;
[0057] Determine the gateway tag update processing method that matches the request type;
[0058] Based on the gateway tag update method that matches the request type, the resource access request is processed to update the gateway tag, thereby obtaining an updated resource access request.
[0059] Obtain the data resource that matches the updated resource access request, and add the target gateway tag to the data resource to obtain the data resource carrying the target gateway tag; the target gateway tag matches the gateway plugin;
[0060] The data resources carrying the target gateway tag are fed back.
[0061] Tenthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:
[0062] Receive and execute an HTML file, and generate a resource access request that matches the HTML file; the HTML file is obtained by the gateway plugin from the server;
[0063] A global interception operation is triggered based on the resource access request. If it is determined that the resource access request does not carry a target gateway tag that matches the gateway plugin, the target gateway tag is added to the resource access request.
[0064] The resource access request carrying the target gateway tag is forwarded to the gateway plugin deployed on the server, and the data resource carrying the target gateway tag is received back from the gateway plugin.
[0065] In the aforementioned resource access processing method, apparatus, computer equipment, storage medium, and computer program product, the request type corresponding to the received resource access request is obtained, and the gateway tag update processing method matching the request type is determined. Then, based on the gateway tag update method matching the request type, the resource access request is processed to update the gateway tag, resulting in an updated resource access request. Further, data resources matching the updated resource access request are obtained, and a target gateway tag is added to the data resources. The target gateway tag matches the gateway plugin to obtain data resources carrying the target gateway tag, and the data resources carrying the target gateway tag are then fed back. This enables the processing of cross-gateway resource access requests through a gateway plugin deployed on a server. Furthermore, based on the gateway plugin, a target gateway tag can be added to data resources during resource access processing, thereby satisfying the access rules of different environments on both sides of the gateway without requiring comprehensive modification, recompilation, and repackaging of the business code in the different environments on both sides of the gateway. This reduces resource consumption during the development of projects with gateways deployed and further improves project development efficiency. Attached Figure Description
[0066] Figure 1 This is an application environment diagram of a resource access processing method in one embodiment;
[0067] Figure 2 This is a flowchart illustrating a resource access processing method in one embodiment;
[0068] Figure 3 This is a schematic diagram illustrating the path modification of a resource access request in one embodiment;
[0069] Figure 4This is a flowchart illustrating the gateway configuration process in one embodiment;
[0070] Figure 5 This is a schematic diagram of path replacement processing based on script resource requests in one embodiment;
[0071] Figure 6 This is a schematic diagram of resource file replacement processing based on script resource requests in one embodiment;
[0072] Figure 7 This is a flowchart illustrating the process of obtaining a script file stream carrying a target gateway tag in one embodiment;
[0073] Figure 8 This is a schematic diagram illustrating the process of obtaining page resource content carrying the target gateway tag in one embodiment;
[0074] Figure 9 This is a schematic diagram of the gateway tag replacement process for a special scenario processing request in one embodiment;
[0075] Figure 10 This is a flowchart illustrating a resource access processing method in another embodiment;
[0076] Figure 11 This is a flowchart illustrating the resource access processing method in another embodiment;
[0077] Figure 12 This is a schematic diagram illustrating the interception principle based on asynchronous requests in one embodiment;
[0078] Figure 13 This is a schematic diagram of the process of adding a target gateway tag based on an XHR request in one embodiment;
[0079] Figure 14 This is a timing diagram of a resource access processing method in one embodiment;
[0080] Figure 15 This is a structural block diagram of a resource access processing device in one embodiment;
[0081] Figure 16 This is a structural block diagram of a resource access processing device in one embodiment;
[0082] Figure 17 This is a schematic diagram of the system architecture of a resource access processing system in one embodiment;
[0083] Figure 18 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0084] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0085] The resource access processing method provided in this application relates to artificial intelligence (AI) technology. AI utilizes digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceiving the environment, acquiring knowledge, and using that knowledge to obtain optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce new intelligent machines that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to have perception, reasoning, and decision-making functions. As a comprehensive discipline, AI technology involves a wide range of fields, including both hardware and software technologies. Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies mainly include computer vision, speech processing, natural language processing, and machine learning / deep learning. Machine learning (ML) is a multidisciplinary field involving probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory. Machine learning is the core of artificial intelligence, a fundamental approach to enabling computers to possess intelligence. Its applications span all areas of artificial intelligence. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and instructional learning.
[0086] With the research and advancement of artificial intelligence (AI) technology, AI is being studied and applied in various fields, such as smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, autonomous driving, drones, robots, smart healthcare, and smart customer service. It is believed that with the development of technology, AI will be applied in more fields and play an increasingly important role.
[0087] The resource access processing method provided in this application specifically relates to deep learning technology in artificial intelligence, and can be applied to, for example... Figure 1In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or located in the cloud or on other network servers. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart vehicle devices, aircraft, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc. Server 104 can be implemented using a standalone server or a server cluster consisting of multiple servers.
[0088] Furthermore, both terminal 102 and server 104 can be used independently to execute the resource access processing method provided in this embodiment, or they can work together to execute the resource access processing method provided in this embodiment. For example, taking the collaborative execution of the resource access processing method provided in this embodiment by terminal 102 and server 104 as an example, when the gateway plugin 106 deployed on server 104 receives a resource access request forwarded by terminal 102 through gateway 108, it obtains the request type corresponding to the received resource access request and determines the gateway tag update processing method matching the request type. Then, according to the gateway tag update method matching the request type, it performs gateway tag update processing on the resource access request to obtain an updated resource access request. Furthermore, the gateway plugin 106 obtains data resources matching the updated resource access request from server 104 and adds a target gateway tag to the data resources to obtain data resources carrying the target gateway tag, wherein the target gateway tag matches the gateway plugin, so as to further forward the data resources carrying the target gateway tag to terminal 102 through gateway 108.
[0089] Similarly, taking the resource access processing method provided in this embodiment of the application, which is executed collaboratively by terminal 102 and server 104, as an example, terminal 102 receives and executes an HTML file to generate a resource access request matching the HTML file. The HTML file is obtained from server 104 by gateway plugin 106 deployed on server 104. After obtaining the HTML file from server 104, gateway plugin 106 adds a gateway prefix to the HTML file and sends the HTML file with the added gateway prefix to terminal 102 through gateway 108. Further, terminal 102 triggers a global interception operation based on the resource access request. If it is determined that the resource access request does not carry a target gateway tag matching gateway plugin 106, the target gateway tag is added to the resource access request, and the resource access request carrying the target gateway tag is forwarded to gateway plugin 106 deployed on server 104 through gateway 108. Terminal 102 then receives data resources carrying the target gateway tag from gateway plugin 106. In this process, the gateway plugin 108 obtains data resources from the server 104 according to the resource access request, adds a target gateway tag to the data resources, and finally sends the data resources carrying the target gateway tag to the terminal 102 through the gateway 108.
[0090] In one embodiment, such as Figure 2 As shown, a resource access processing method is provided. This is illustrated using an example where the method is executed by a computer device. It can be understood that the computer device can be... Figure 1 The terminal 102 shown can also be a server 104 with a gateway plugin 106 deployed, or a system consisting of terminal 102 and server 104, and is implemented through interaction between terminal 102 and server 104. In this embodiment, the resource access processing method specifically includes the following steps:
[0091] Step S202: Obtain the request type corresponding to the received resource access request.
[0092] In project development, when deploying the project to a terminal network environment that also supports local access, it may be necessary to isolate the terminal's network environment from the server's due to development environment requirements or project limitations. A gateway is then deployed to connect these two isolated network environments, allowing the terminal to access the server's resources for project development, feature deployment, and other subsequent processing. The terminal and server perform request forwarding and data resource forwarding through the gateway. Only requests or data resources carrying the gateway prefix can be recognized and forwarded by the gateway; if the request or data resource does not carry the gateway prefix, it cannot be recognized by the gateway, resulting in forwarding failure.
[0093] Specifically, the server is equipped with a gateway plugin. This plugin removes the gateway prefix from requests forwarded by the terminal through the gateway, and then sends the request to the server. The gateway plugin further retrieves data resources matching the request from the server, adds a gateway tag to the data resources, and then sends the tagged data resources to the terminal through the gateway. The gateway tag can be understood as a path prefix identified by the gateway.
[0094] Before adding gateway tags to data resources, the gateway plugin needs to modify the request path. Specifically, it adds the target gateway tag matching the gateway plugin to the request path, preprocessing the request path of the data resources the request needs to acquire. This allows for dynamic modification based on the existing deployment project, enabling cross-gateway access for requests and data resources. For example, in this embodiment, the gateway plugin used for request path preprocessing can be the handle_netgate_koa2_plugin plugin. By deploying the handle_netgate_koa2_plugin plugin on the server and configuring the corresponding target gateway tag in the plugin, the target gateway tag matching the gateway plugin is added to the request path.
[0095] Furthermore, based on the addition of the target gateway tag to the request path, the previously cleared gateway prefix is re-added to the data resource so that the gateway can recognize the gateway prefix and then forward the data resource through the gateway.
[0096] For example, such as Figure 3 This provides a schematic diagram illustrating the modification of a resource access request path, for reference. Figure 3 It can be seen that by obtaining the root directory of the resource access request initiated by the terminal and adding a target gateway marker to the root directory, for example, if the data resource associated with an application installed on the server needs to be accessed (this application can be represented by "app1"), then "app1" is added as the target gateway marker to the root directory. Therefore, when internal resources of application app1 need to be accessed, these internal resources can be called through the modified root directory. The server side does not need to modify its business code or re-deploy; it can obtain the required data resource from the server based on the modified request path.
[0097] In one embodiment, before obtaining the request type corresponding to the received resource access request, the method further includes:
[0098] Receive a resource access address carrying a gateway prefix, and remove the gateway prefix to obtain a resource access address with the gateway prefix removed; obtain the HTML file corresponding to the resource access address without the gateway prefix, and add the gateway prefix to the HTML file to obtain an HTML file with the gateway prefix added; send back the HTML file with the gateway prefix added; the HTML file with the gateway prefix added is used to trigger a resource access request, and the resource access request carries the gateway prefix; receive a resource access request and remove the gateway prefix carried in the resource access request.
[0099] Specifically, the gateway plugin receives the resource access address (URL, or Uniform Resource Locator) forwarded by the terminal through the gateway. Since the resource access address needs to be forwarded through the gateway, it carries a gateway prefix. The gateway identifies the gateway prefix and forwards the resource access address to the gateway plugin. The gateway plugin then removes the gateway prefix from the resource access address and sends the prefix-free resource access address to the server. This causes the server to send the gateway plugin the corresponding HTML file (Hypertext Markup Language file) to the resource access address.
[0100] Furthermore, since the HTML file needs to be forwarded to the terminal through the gateway, the gateway plugin, upon receiving the HTML file, adds a gateway prefix to it and forwards the prefixed HTML file to the terminal through the gateway. The terminal, upon receiving the HTML file with the gateway prefix, parses it and triggers a resource access request. Because the HTML file carries the gateway prefix, the resource access request triggered based on the HTML file also carries the gateway prefix. The terminal sends the resource access request with the gateway prefix to the gateway plugin through the gateway. The gateway plugin receives the resource access request, removes the gateway prefix from the request, and sends the prefix-free resource access request to the server to retrieve the data resource matching the request.
[0101] In one embodiment, such as Figure 4 As shown, a gateway configuration processing flow is provided, which includes, before receiving the resource access address forwarded by the terminal through the gateway, the following steps:
[0102] If a gateway configuration request is detected, the gateway configuration information carried in the request is obtained; based on the gateway plugin that matches the gateway configuration information, the terminal is configured with gateway information; the gateway plugin carries a gateway prefix for cross-gateway access.
[0103] Specifically, when a gateway configuration request is detected, it is determined whether a gateway plugin needs to be introduced. If it is determined that a gateway plugin needs to be introduced, the gateway configuration information carried in the gateway configuration request is obtained, and the gateway plugin that matches the gateway configuration information is further determined based on the gateway configuration information. Then, the gateway configuration process is performed on the terminal based on the gateway plugin that matches the gateway configuration information.
[0104] Since the gateway plugin carries a gateway prefix for cross-gateway access, when configuring the gateway, it is necessary to configure the gateway for the terminal according to the gateway prefix carried by the gateway plugin. This ensures that the resource access address or resource access request sent by the terminal carries the gateway prefix so that it can be recognized by the gateway and forwarded.
[0105] Furthermore, after configuring the gateway on the terminal, the terminal needs to be restarted for the gateway configuration to take effect and enable cross-gateway access.
[0106] In one embodiment, as shown in Table 1 (Configuration Parameter Information Table), various configuration parameters are provided for different configuration requirements, including the parameter name, type, whether it is required, description information, and default value, etc., to meet diverse configuration needs:
[0107] Table 1 Configuration Parameter Information Table
[0108]
[0109] As shown in Table 1, for different configuration requirements, such as for strings that need to have gateway tags added, the corresponding configuration parameter "appPrefix" can be set. When it is necessary to modify the path of the root directory where dynamic resources are stored, the root directory where dynamic resources are stored before the tag is inserted can be obtained first according to the configuration parameter "rawPrefix", and the path of the root directory where dynamic resources are stored can be modified to add the corresponding gateway tag.
[0110] Similarly, for example, if the path to access the homepage needs to be modified, the path to access the homepage can be determined according to the configuration parameter "rootRouter", and a gateway tag can be added to the path to access the homepage. If the path to access the HTML page on the server side needs to be modified, the path to access the HTML page on the server side can be determined according to the configuration parameter "viewDir", and a gateway tag can be added to the path to access it.
[0111] During project development, required static resources are stored in the `static` directory (i.e., static storage). If a resource is not static, the `rawPrefix` configuration parameter determines the root directory for dynamic resources. The `ProjName` configuration parameter is used to specify the module name when it's not `index`. Similarly, the `indexName` configuration parameter represents the unified module name used after Wepack bundling. This parameter is used when all bundled resources are consistent, such as `index`.
[0112] Furthermore, when there are multiple bundled JS or CSS files containing business code, you can add the names of all bundled JS files to the "jsFiles" configuration parameter and the names of all bundled CSS files to the "cssFlies" configuration parameter.
[0113] Step S204: Determine the gateway tag update processing method that matches the request type.
[0114] The request types corresponding to resource access requests specifically include script resource requests, page requests, special scenario processing requests, and other requests. Script resource requests include resource requests for CSS (Cascading Style Sheet) script files / JS (JavaScript) script files, as well as resource requests for image / text resources. Page requests include single-page requests and multi-page requests. Other requests include asynchronous transmission requests (i.e., AJAX requests, where AJAX requests use asynchronous data transmission between the terminal and the server).
[0115] Specifically, for different request types of resource access requests, there are matching gateway tag update processing methods. For example, if the request type of the resource access request is a script resource request, then a first gateway tag update processing method matching the script resource request is further determined. If the request type corresponding to the resource access request is a page request, then a second gateway tag update processing method matching the page request is determined. Similarly, if the request type corresponding to the resource access request is a special scenario processing request, then a third gateway tag update processing method matching the special scenario processing request is further determined.
[0116] Step S206: Based on the gateway tag update method that matches the request type, perform gateway tag update processing on the resource access request to obtain the updated resource access request.
[0117] The gateway tag update methods include: a first gateway tag update processing method matching script resource requests, a second gateway tag update processing method matching page requests, and a third gateway tag update processing method matching special scenario processing requests. The target gateway tag matches the gateway plugin; that is, when updating the gateway tag through a gateway plugin, a target gateway tag is added to the request path of the data resource to be accessed by the resource access request. This target gateway tag matches the gateway plugin.
[0118] Specifically, if the resource access request is a script resource request, then based on the first gateway tag update processing method, a target gateway tag matching the gateway plugin is added to the file storage path to obtain an updated script resource request. Similarly, if the request type corresponding to the resource access request is a page request, then according to the second gateway tag update processing method, a target gateway tag matching the gateway plugin is added to the resource access address to obtain an updated page request. Likewise, if the request type corresponding to the resource access request is a special scenario processing request, then according to the third gateway tag update processing method, a target gateway tag is added to the storage path to obtain an updated special scenario processing request.
[0119] Specifically, the gateway tag update processing for resource access requests involves preprocessing the request path of the resource access request. This means adding a target gateway tag to the request path of the resource access request to obtain the updated request path, thus achieving preprocessing for modifying the request path. Subsequently, the data resources of the request with the modified path can be obtained from the server, and the target gateway tag can be added to the data resources to provide feedback to the terminal.
[0120] In one embodiment, if the request type corresponding to the resource access request is another type of request, such as an asynchronous transfer request, the gateway plugin directly removes the gateway prefix from the request. This allows the asynchronous transfer request without the gateway prefix to be sent to the server. The server then adds the gateway prefix to the HTML file it forwards before forwarding it to the terminal. Further, the terminal parses the HTML file, triggering an XHR request (Extended Hypertext Transfer Request) corresponding to the asynchronous transfer request. The terminal intercepts the XHR request and determines whether it carries a target gateway tag. If the XHR request does not carry a target gateway tag, it needs to be added to the XHR request. The XHR request with the target gateway tag is then forwarded to the gateway plugin through the gateway. The gateway plugin then sends the XHR request to the server to retrieve the data resources from the server.
[0121] Step S208: Obtain the data resource that matches the update resource access request, and add the target gateway tag to the data resource to obtain the data resource carrying the target gateway tag.
[0122] Specifically, the gateway plugin extracts data resources that match the update resource access request from the server and adds a target gateway tag to the data resources to obtain data resources carrying the target gateway tag.
[0123] The update resource access requests include: update script resource requests, update page requests, and update special scenario processing requests. The data resources that match the update resource access requests include: script file streams carrying target gateway tags that match the update script resource requests, page resource content carrying target gateway tags that match the update page requests, and data resources carrying target gateway tags that match the update special scenario processing requests.
[0124] Step S210: Feedback of data resources carrying the target gateway tag.
[0125] Specifically, the gateway plugin will carry the data resources marked by the target gateway and forward them to the terminal through the gateway. After receiving the data resources, the terminal will carry out further project development and deployment processing.
[0126] In the above resource access processing method, the request type corresponding to the received resource access request is obtained, and the gateway tag update processing method matching the request type is determined. Then, according to the gateway tag update method matching the request type, the resource access request is processed to update the gateway tag, thus obtaining an updated resource access request. Further, the data resource matching the updated resource access request is obtained, and a target gateway tag is added to the data resource. The target gateway tag matches the gateway plugin to obtain data resources carrying the target gateway tag, and the data resources carrying the target gateway tag are then fed back. This method enables the processing of cross-gateway resource access requests through a gateway plugin deployed on the server. Furthermore, based on the gateway plugin, target gateway tags can be added to data resources during resource access processing, thereby satisfying the access rules of different environments on both sides of the gateway without requiring comprehensive modification, recompilation, and repackaging of the business code in the different environments on both sides of the gateway. This reduces resource consumption during the development of projects with gateways deployed and further improves project development efficiency.
[0127] In one embodiment, the step of obtaining an updated resource access request, namely determining the gateway tag update processing method matching the request type, and performing gateway tag update processing on the resource access request according to the gateway tag update method matching the request type, includes:
[0128] If the request type of the resource access request is a script resource request, determine the first gateway tag update processing method that matches the script resource request, and the file storage path of the script resource file that matches the script resource request; based on the first gateway tag update processing method, add the target gateway tag that matches the gateway plugin to the file storage path to obtain the updated script resource request.
[0129] Specifically, by obtaining the content type of the resource access request (i.e., the content type, used to define the type of network file and the encoding of the webpage, i.e., the content type of the actual returned content, determining in what form and with what specific encoding the terminal will read the corresponding network file), when the request type of the resource access request is determined to be a script resource request based on the content type, the first gateway tag update processing method matching the script resource request is determined. The first gateway tag update processing method specifically manifests as: adding a target gateway tag matching the gateway plugin to the file storage path.
[0130] Furthermore, if the resource access request type is a script resource request, it is also necessary to determine the file storage path of the script resource file that matches the script resource request. Then, based on the first gateway tag update processing method, the target gateway tag that matches the gateway plugin is added to the file storage path to obtain the updated script resource request.
[0131] In one embodiment, for script resource requests such as CSS and JS script files, the URL is identified and dynamically replaced within the homepage of the HTML file to achieve the purpose of preprocessing the request path. Here, URL stands for Uniform Resource Locator, which can also be understood as a resource access address. By replacing the resource access address path within the homepage of the HTML file, the resource access address is preprocessed so that when data resources are needed later, they can be obtained based on the request path that has been replaced.
[0132] For example, such as Figure 5 This provides a schematic diagram of path replacement processing based on script resource requests, see reference. Figure 5 It can be seen that, Figure 5 The documentation provides preprocessing for CSS and JavaScript files. Specifically, it adds a target gateway tag matching the gateway plugin to the resource access URL of both the CSS and JavaScript files, ultimately resulting in a resource access URL carrying the target gateway tag. For example, it adds a tag like... Figure 5 The target gateway tag shown is “ / wangjian / zstp / web / static / ”.
[0133] In one embodiment, for script resource requests such as image resources or text resources, the URLs of the corresponding CSS script files and JS script files are identified and dynamically replaced, thus achieving preprocessing for modifying the request path.
[0134] To give a simple example, Figure 6 A schematic diagram of resource file replacement processing based on script resource requests is provided, for reference. Figure 6 As can be seen, taking image resources as resource files and JavaScript script files as examples, the terminal (i.e. Figure 6 The browser shown sends a JavaScript file request, representing an image resource request, to the gateway plugin. The gateway plugin dynamically replaces the JavaScript file request, that is, it replaces the path of the resource access address (i.e., URL) of the JavaScript file, adds a target gateway tag to the resource access address of the JavaScript file, and sends the resource access address with the target gateway tag to the server (i.e., the browser). Figure 6 (As shown in the Node server example), the server sends the JavaScript file corresponding to the JavaScript file request to the gateway plugin.
[0135] Furthermore, the gateway plugin dynamically replaces JavaScript files, adding a target gateway tag to them before sending the tagged JavaScript file to the terminal. Upon receiving the tagged JavaScript file, the terminal runs it, triggering an image request carrying the target gateway tag. The terminal then sends this image request to the gateway plugin, which removes the target gateway tag before sending it to the server. The server returns the corresponding image resource to the gateway plugin, which adds the target gateway tag to the image resource and then sends it back to the terminal via the gateway.
[0136] Since the JavaScript files for image resources have been preprocessed and already carry the target gateway tag, the image resources can be recognized by the gateway deployed between the server and the terminal. Similarly, the obtained image resources can also be recognized by the gateway so that the image resources can be forwarded to the terminal through the gateway.
[0137] In this embodiment, when the request type of the resource access request is a script resource request, the file storage path of the script resource file matching the script resource request is determined. Then, according to the first gateway tag update processing method matching the script resource request, a target gateway tag matching the gateway plugin is added to the file storage path, resulting in an updated script resource request. This achieves targeted gateway tag update processing by determining the matching gateway tag update processing method based on the specific request type, avoiding redundant operations and further improving the efficiency of gateway tag update processing.
[0138] In one embodiment, such as Figure 7 This provides a schematic diagram of obtaining a script file stream carrying a target gateway tag, see reference. Figure 7 It can be seen that the steps of obtaining data resources that match the update resource access request, and adding the target gateway tag to the data resources to obtain data resources carrying the target gateway tag specifically include:
[0139] Based on the file storage path, obtain the script resource file that matches the update script resource request; convert the script resource file into a script string, add the target gateway tag to the script string, and obtain a script string with the target gateway tag; convert the script string with the target gateway tag into script cache data, and output the script cache data as a file stream, and obtain a script file stream carrying the target gateway tag.
[0140] Specifically, if the update resource access request is an update script resource request, then the file storage path of the script resource file that matches the update script resource request is obtained, and the script resource file that matches the update script resource request is obtained based on the file storage path.
[0141] Furthermore, since the script resource files are transmitted on the server as streams, the replacement is specifically performed using a pipelined approach. This includes: obtaining the script resource file stream that matches the update request; converting the script resource file stream into a script string; and adding the target gateway flag to the script string to obtain a script string with the target gateway flag. The script string with the target gateway flag is then converted into script cache data, and the script cache data is output as a file stream to obtain a script file stream carrying the target gateway flag.
[0142] In one embodiment, if the resource access request type is a script resource request, determining the file storage path of the script resource file matching the script resource request includes:
[0143] If the request type of the resource access request is a script resource request, obtain the resource access address that matches the script resource request; parse the information based on the resource access address to obtain the file name of the script resource file that matches the script resource request; determine the file storage path of the script resource file that matches the script resource request based on the file name and the configuration information of the gateway plugin.
[0144] Specifically, if the resource access request type is a script resource request, such as a script resource request for a CSS script file or a JS script file, then the resource access address matching the script resource request is obtained, and the information of the resource access address is parsed to obtain the file name of the script resource file matching the script resource request.
[0145] Furthermore, by obtaining the gateway plugin's configuration information and based on the gateway plugin's configuration information and the filename of the script resource file, the file storage path of the script resource file matching the script resource request is determined. The gateway plugin's configuration information may include different configuration parameters from Table 1 (Configuration Parameter Information Table), such as rawPrefix (used to determine the root directory for dynamic resources before the insertion mark), jsFiles (used to add the package name to the field when there are multiple bundled files containing business code JS), and cssFlies (used to add the package name to the field when there are multiple bundled files containing business code CSS), etc.
[0146] In this embodiment, based on the file storage path, the script resource file matching the update script resource request is obtained. The script resource file is converted into a script string, and the target gateway tag is added to the script string to obtain a script string with the target gateway tag. Further, by converting the script string with the target gateway tag into script cache data and outputting the script cache data as a file stream, a script file stream carrying the target gateway tag is obtained. This achieves the determination of the matching data resource update method based on the specific request type. When the resource access request is an update script resource request, a pipe-like replacement method is specifically adopted, including extracting the script resource file stream, converting the script resource file stream into a string and adding the target gateway tag, and converting the script string with the target gateway tag into script cache data and outputting the script cache data as a file stream, thereby obtaining a script file stream carrying the target gateway tag. This allows for accurate determination of the specific location that needs to be replaced and updated based on the string, avoiding replacement errors and further improving the efficiency of script file stream replacement processing.
[0147] In one embodiment, the step of obtaining an updated resource access request, namely determining the gateway tag update processing method matching the request type, and performing gateway tag update processing on the resource access request according to the gateway tag update method matching the request type, includes:
[0148] If the request type corresponding to the resource access request is a page request, determine the second gateway tag update processing method that matches the page request, and the resource access address of the page resource content that matches the page request; according to the second gateway tag update method, add the target gateway tag that matches the gateway plugin to the resource access address to obtain the updated page request.
[0149] Specifically, by obtaining the content type of the resource access request, when the request type corresponding to the resource access request is determined to be a page request based on the content type, the second gateway tag update processing method matching the page request is determined. The second gateway tag update processing method is specifically implemented as follows: adding the target gateway tag matching the gateway plugin to the resource access address to obtain the updated page request.
[0150] Furthermore, if it is determined that the request type corresponding to the resource access request is a page request, then it is also necessary to determine the resource access address of the page resource content that matches the page request. Then, according to the second gateway tag update method, the target gateway tag that matches the gateway plugin is added to the resource access address to obtain the updated page request.
[0151] In one embodiment, such as Figure 8 As shown, a processing flow for obtaining page resource content carrying the target gateway tag is provided, referring to... Figure 8 It can be seen that the steps of obtaining data resources that match the update resource access request, and adding the target gateway tag to the data resources to obtain data resources carrying the target gateway tag specifically include:
[0152] Based on the resource access address, obtain the page resource content that matches the page request; obtain the interception code associated with the cross-gateway access request; identify the title tag from the page information resource; based on the page resource content, add the target gateway tag and the interception code after the title tag to obtain the page resource content carrying the target gateway tag.
[0153] Specifically, if the resource access request is a page request, the resource access address matching the page request is obtained, and based on the resource access address, the page resource content matching the page request is obtained, and the title tag is further identified from the page information resource.
[0154] Since the current communication concerns communication between a terminal and a server with a gateway deployed, the access requests involved in the communication process can be understood as cross-gateway access requests. Therefore, it is also necessary to obtain the interception code associated with the cross-gateway access requests. This interception code associated with cross-gateway access requests is executed on the terminal (i.e., the browser) to intercept the triggered XHR requests when the resource access request is an asynchronous transmission request.
[0155] Furthermore, based on the page resource content, after the title tag in the page resource content, a target gateway tag and interception code are added to obtain page resource content carrying the target gateway tag. Here, the page resource content corresponding to the page request can be understood as an HTML file. The title tag in the HTML file, specifically the `<head>` tag, is followed by the target gateway tag and interception code to obtain page resource content carrying the target gateway tag.
[0156] In one embodiment, a page request includes a single-page request and a multi-page request. A single-page request corresponds to a first resource access address, while a multi-page request corresponds to multiple second resource access addresses. If the request type corresponding to a resource access request is a page request, the step of determining the resource access address of the page resource content matching the page request specifically includes:
[0157] If the request type corresponding to the resource access request is a page request, obtain the number of page requests; if the number of requests determines that the page request is a single-page request, obtain the first resource access address that matches the single-page request; or if the number of requests determines that the page request is a multi-page request, obtain the resource address storage array corresponding to the multi-page request; based on the resource address storage array, match and obtain multiple second resource access addresses corresponding to the multi-page request.
[0158] Specifically, if the request type corresponding to the resource access request is a page request, then the number of page requests is obtained, and the specific request type is determined based on the number of page requests.
[0159] Furthermore, if the page request is determined to be a single-page request based on the number of requests, then the first resource access address matching the single-page request is obtained; if the page request is determined to be a multi-page request based on the number of requests, then the resource address storage array corresponding to the multi-page request is obtained, and multiple second resource access addresses corresponding to the multi-page request are obtained based on the resource address storage array.
[0160] In this context, a single-page request indicates that the application installed on the server has a single entry point, i.e., only one HTML file. By loading this HTML file, all the functions deployed by the corresponding application can be obtained. A multi-page request, on the other hand, indicates that the application installed on the server has multiple entry points, i.e., multiple HTML files. This requires enumeration and matching using a resource address storage array (i.e., the htmlFileArr array). Specifically, the gateway plugin uses the resource address storage array to match and obtain multiple secondary resource access addresses corresponding to the multi-page request.
[0161] In this embodiment, if the request type corresponding to the resource access request is a page request, the second gateway tag update processing method matching the page request and the resource access address of the page resource content matching the page request are determined. Based on the second gateway tag update method, a target gateway tag matching the gateway plugin is added to the resource access address to obtain the updated page request. This achieves targeted gateway tag update processing by determining the matching gateway tag update processing method based on the specific request type, avoiding redundant operations and further improving the efficiency of gateway tag update processing.
[0162] In one embodiment, such as Figure 9 As shown, a processing flow for gateway tag replacement processing based on special scenario processing requests is provided, referring to... Figure 9 It can be seen that the steps to obtain an updated resource access request, namely determining the gateway tag update processing method matching the request type, and performing gateway tag update processing on the resource access request according to the gateway tag update method matching the request type, specifically include:
[0163] If the request type corresponding to the resource access request is a special scenario processing request, determine the third gateway tag update processing method that matches the special scenario processing request, as well as the additional attribute information that matches the special scenario processing request; if the special scenario processing request is determined to be located in the preset special request queue based on the additional attribute information, obtain the storage path of the file stream that matches the special scenario processing; according to the third gateway tag update processing method, add the target gateway tag to the storage path to obtain the update special scenario processing request.
[0164] When determining whether a resource access request falls under the category of special scenario handling, it's necessary to first identify if the request type is a script resource request. If it is, further investigation is needed to determine if a special scenario is involved. For example, for image resource requests, image resources are typically bundled using Webpack (a bundling tool). This means that image resource requests can usually be handled by preprocessing the JavaScript file and then replacing and updating the request path to add a target gateway tag to the request path and the image resource. However, there are special scenarios where dynamic requests via JavaScript or requests based on HTML files are required instead of Webpack bundling. In these cases, additional attributes are needed to match the requested image resource.
[0165] Specifically, if the request type corresponding to the resource access request is a special scenario processing request, then the third gateway tag update processing method matching the special scenario processing request is determined, and additional attribute information matching the special scenario processing request is obtained. For example, the additional attribute information extraFilesArr is used to match the requested image resource. The third gateway tag update processing method is specifically manifested as: adding the target gateway tag to the storage path to obtain the update special scenario processing request.
[0166] Furthermore, by obtaining a preset special request queue and determining whether a special scenario processing request is located in the preset special request queue, specifically by determining whether a special scenario processing request is located in the preset special request queue based on additional attribute information.
[0167] If it is determined that the special scenario processing request is located in the preset special request queue, the storage path of the file stream that matches the special scenario processing is obtained, and the target gateway tag is added to the storage path according to the third gateway tag update processing method to obtain the updated special scenario processing request.
[0168] In one embodiment, the step of obtaining a data resource matching the update resource access request and adding a target gateway tag to the data resource to obtain a data resource carrying the target gateway tag includes:
[0169] Obtain the file stream that matches the special scenario processing request, and add the target gateway tag to the file stream to obtain the file stream carrying the target gateway tag.
[0170] Specifically, if the resource access request is a special scenario processing request, then the file stream that matches the update special scenario processing request is obtained, and the target gateway tag is added to the file stream to obtain a file stream carrying the target gateway tag.
[0171] In this embodiment, if the request type corresponding to the resource access request is a special scenario processing request, the third gateway tag update processing method matching the special scenario processing request and the additional attribute information matching the special scenario processing request are determined. If, based on the additional attribute information, it is determined that the special scenario processing request is located in a preset special request queue, the storage path of the file stream matching the special scenario processing is obtained. Furthermore, according to the third gateway tag update processing method, the target gateway tag is added to the storage path to obtain the updated special scenario processing request. This achieves the goal of determining the matching gateway tag update processing method based on the specific request type, enabling targeted gateway tag update processing operations for the corresponding request type, avoiding other redundant processing operations, and further improving the efficiency of gateway tag update processing for the current request type.
[0172] In one embodiment, such as Figure 10 As shown, a resource access processing method is provided, which specifically includes the following steps:
[0173] Step S1001: Receive the resource access address carrying the gateway prefix, and clear the gateway prefix to obtain the resource access address with the gateway prefix cleared.
[0174] Step S1002: Obtain the HTML file corresponding to the resource access address excluding the gateway prefix, and add the gateway prefix to the HTML file to obtain the HTML file with the gateway prefix added.
[0175] Step S1003: Feedback is provided with an HTML file containing the gateway prefix. This HTML file with the gateway prefix is used to trigger resource access requests, which carry the gateway prefix.
[0176] Step S1004: Receive resource access request and clear the gateway prefix carried in the resource access request.
[0177] Step S1005: Obtain the request type corresponding to the received resource access request.
[0178] Step S1006: If the request type of the resource access request is a script resource request, determine the first gateway tag update processing method that matches the script resource request and the file storage path of the script resource file that matches the script resource request.
[0179] Step S1007: Based on the first gateway tag update processing method, add the target gateway tag that matches the gateway plugin to the file storage path to obtain the update script resource request.
[0180] Step S1008: If the request type of the resource access request is a script resource request, obtain the resource access address that matches the script resource request.
[0181] Step S1009: Based on the resource access address, perform information parsing to obtain the file name of the script resource file that matches the script resource request.
[0182] Step S1010: Determine the file storage path of the script resource file that matches the script resource request based on the file name and the configuration information of the gateway plugin.
[0183] Step S1011: Based on the file storage path, obtain the script resource file that matches the update script resource request.
[0184] Step S1012: Convert the script resource file into a script string, add the target gateway tag to the script string, and obtain the script string with the target gateway tag added.
[0185] Step S1013: Convert the script string with the target gateway tag into script cache data, and output the script cache data as a file stream to obtain a script file stream carrying the target gateway tag.
[0186] After executing step S1005, execute steps S1014 to S1015. Step S1019: If the request type corresponding to the resource access request is a page request, obtain the number of page requests.
[0187] Step S1015: If the page request is determined to be a single-page request based on the number of requests, obtain the first resource access address that matches the single-page request.
[0188] Step S1016: If the page request is determined to be a multi-page request based on the number of requests, obtain the resource address storage array corresponding to the multi-page request.
[0189] Step S1017: Based on the resource address storage array, match and obtain multiple second resource access addresses corresponding to the multi-page request.
[0190] Step S1018: Based on the resource access address, obtain the page resource content that matches the page request, and identify the title tag from the page information resource.
[0191] Step S1019: Obtain the interception code associated with the cross-gateway access request, and based on the page resource content, add the target gateway tag and the interception code after the title tag to obtain the page resource content carrying the target gateway tag.
[0192] After executing step S1005, execute steps S1020 to S1014. Step S1020: If the request type corresponding to the resource access request is a special scenario processing request, determine the third gateway tag update processing method that matches the special scenario processing request, as well as the additional attribute information that matches the special scenario processing request.
[0193] Step S1021: If, based on additional attribute information, it is determined that the special scenario processing request is located in a preset special request queue, obtain the storage path of the file stream that matches the special scenario processing.
[0194] Step S1022: According to the third gateway tag update processing method, add the target gateway tag in the storage path to obtain the update special scenario processing request.
[0195] Step S1023: Obtain the file stream that matches the update special scenario processing request, and add the target gateway tag to the file stream to obtain the file stream carrying the target gateway tag.
[0196] After executing step S1013, or step S1019, or step S1023, execute step S1024. Step S1024: Feed back data resources carrying the target gateway tag. The data resources carrying the target gateway tag include script file streams carrying the target gateway tag, page resource content carrying the target gateway tag, and file streams carrying the target gateway tag.
[0197] In the above resource access processing method, the request type corresponding to the received resource access request is obtained, and the gateway tag update processing method matching the request type is determined. Then, according to the gateway tag update method matching the request type, the resource access request is processed to update the gateway tag, thus obtaining an updated resource access request. Further, the data resource matching the updated resource access request is obtained, and a target gateway tag is added to the data resource. The target gateway tag matches the gateway plugin to obtain data resources carrying the target gateway tag, and the data resources carrying the target gateway tag are then fed back. This method enables the processing of cross-gateway resource access requests through a gateway plugin deployed on the server. Furthermore, based on the gateway plugin, target gateway tags can be added to data resources during resource access processing, thereby satisfying the access rules of different environments on both sides of the gateway without requiring comprehensive modification, recompilation, and repackaging of the business code in the different environments on both sides of the gateway. This reduces resource consumption during the development of projects with gateways deployed and further improves project development efficiency.
[0198] In one embodiment, such as Figure 11 This paper provides a resource access processing method, which is illustrated by taking the method executed by a terminal as an example. In this embodiment, the resource access processing method specifically includes:
[0199] Step S1102: Receive and execute the HTML file, and generate a resource access request that matches the HTML file. The HTML file is obtained by the gateway plugin from the server.
[0200] Specifically, in this embodiment, the terminal can be a browser. The browser receives an HTML file from the server via a gateway plugin, which is then forwarded by the gateway. The browser parses and runs the HTML file, triggering the generation of a resource access request that matches the HTML file.
[0201] Furthermore, before receiving the HTML file, resource access operation detection processing is required. If a resource access operation triggered by the terminal is detected, the resource access address corresponding to the input resource access operation is obtained, and then the resource access address is sent to the server so that the server can return the HTML file corresponding to the resource access address.
[0202] In one embodiment, before receiving and executing the HTML file and generating a resource access request matching the HTML file, the method further includes:
[0203] If a resource access operation is detected, obtain the resource access address corresponding to the resource access operation; the resource access address carries the gateway prefix.
[0204] The resource access address carrying the gateway prefix is forwarded to the gateway plugin. The gateway plugin removes the gateway prefix from the resource access address and sends the obtained resource access address with the gateway prefix removed to the server. The gateway plugin is used to receive the HTML file corresponding to the resource access address with the gateway prefix removed from the server, add the gateway prefix to the HTML file, and forward the HTML file with the gateway prefix added to the terminal.
[0205] Specifically, before detecting resource access operations, it's necessary to determine whether a gateway configuration request has been detected. If so, the gateway configuration information carried in the request is obtained, and the gateway plugin used for gateway configuration processing is identified based on this information. Then, gateway configuration processing is performed on the terminal according to the gateway plugin. Since the gateway plugin carries a gateway prefix for cross-gateway access, after gateway configuration processing on the terminal using the gateway plugin, the resource access address corresponding to the triggered resource access operation carries the gateway prefix, enabling the gateway to recognize and forward the request.
[0206] Furthermore, if a resource access operation is detected, the resource access address corresponding to the operation is obtained, and the resource access address carrying the gateway prefix is forwarded to the gateway plugin through the gateway. The gateway plugin removes the gateway prefix from the received resource access address and sends the prefix-free resource access address to the server. The server then sends the HTML file corresponding to the resource access address back to the gateway plugin. Upon receiving the HTML file, the gateway plugin adds a gateway target tag to the request path of the HTML file, adds a gateway prefix to the HTML file, and sends the prefixed HTML file to the terminal through the gateway. The terminal then receives and executes the HTML file, triggering the generation of a resource access request matching the HTML file.
[0207] Step S1104: Trigger a global interception operation based on the resource access request. If it is determined that the resource access request does not carry a target gateway tag that matches the gateway plugin, add the target gateway tag to the resource access request.
[0208] Specifically, for the terminal, when the received resource access request is an asynchronous transmission request, a corresponding global interception operation needs to be performed on the XHR request triggered by the asynchronous transmission request. Specifically, since the URL format of the XHR request can vary and is not unique, it cannot be directly replaced by pattern determination. That is, the same method used for request path replacement preprocessing as for other page requests or script resource file requests cannot be applied. Therefore, a request interception method is needed to proxy the XHR request to the open interface (i.e., the interface used to initialize the XHR request) and determine whether the XHR request carries the target gateway tag. If not, the target gateway tag needs to be added back to the XHR request.
[0209] Specifically, when the resource access request received by the terminal is an asynchronous transmission request, the corresponding global interception operation is performed on the XHR request triggered by the asynchronous transmission request, and the XHR request is proxied to the open interface. The open interface is then used to further determine whether the XHR request carries the target gateway tag.
[0210] Furthermore, if it is determined that the XHR request carries a target gateway tag, a gateway prefix is added to the XHR request carrying the target gateway tag, and the XHR request is forwarded to the gateway plugin through the gateway. The gateway plugin can then remove the gateway prefix from the XHR request and send the XHR request with the gateway prefix removed to the server to obtain the corresponding data resources from the server.
[0211] Specifically, if it is determined that the XHR request does not carry a target gateway tag, the target gateway tag is added to the XHR request, and a gateway prefix is added to the XHR request with the target gateway tag to forward the XHR request to the gateway plugin through the gateway. Similarly, the gateway plugin can remove the gateway prefix from the XHR request and send the XHR request with the gateway prefix removed to the server to obtain the corresponding data resources from the server.
[0212] In one embodiment, such as Figure 12 As shown, a schematic diagram of the interception principle based on asynchronous requests is provided. Figure 12 As we can see, the XHR request that can be triggered by the terminal (i.e., the browser) itself, namely the Real XMLhttpRequest request, is an object that exists in the browser itself. The XMLhttpRequest Proxy is an object obtained by rewriting the original RealXMLhttpRequest. It can be understood as adding a proxy wrapper to the outside of Real XMLhttpRequest. Before calling the real Real XMLhttpRequest, the proxy wrapper performs the operations that need to be performed.
[0213] Among them, reference Figure 12 As can be seen, proxy method represents the overridden method, where open indicates initializing the XHR request, abort indicates aborting the XHR request, setheader indicates setting the header of the XHR request, and send indicates sending the XHR request.
[0214] Step S1106: Forward the resource access request carrying the target gateway tag to the gateway plugin deployed on the server, and receive the data resource carrying the target gateway tag from the gateway plugin.
[0215] Specifically, the terminal sends a resource access request carrying a target gateway tag to the gateway. The gateway identifies the request and forwards it to a gateway plugin deployed on the server. Since the resource access request needs to be forwarded through the gateway, after the gateway plugin configures the terminal, the resource access request sent from the terminal carries a gateway prefix. The gateway plugin removes the gateway prefix from the resource access request and sends the request to the server to retrieve data resources. After adding the target gateway tag to the data resources retrieved from the server, the data resources carrying the target gateway tag are forwarded to the terminal through the gateway.
[0216] Furthermore, when the gateway plugin modifies the request path and adds gateway tags for resource access requests and data resources, it specifically modifies and replaces the content within the access request and data resource. The gateway prefix serves to be recognized by the gateway. That is, if the gateway plugin clears the gateway prefix of the request or data resource, the gateway prefix must be added again when forwarding is needed to ensure that it can be recognized by the gateway.
[0217] In one embodiment, such as Figure 13 As shown, a processing flow for adding a target gateway tag based on an XHR request is provided, referring to... Figure 13 As can be seen, for XHR requests, the terminal performs a global interception operation and proxies the XHR request to the open interface. It then determines whether the XHR request carries a target gateway identifier. If not, the open method needs to be overridden, meaning the URL is replaced during the request initialization phase to add the target gateway identifier to the XHR request. When it is determined that the XHR request carries the target gateway identifier, or that the target gateway identifier has already been added to the XHR request, the original methods (including open, abort, setheader, and send methods) are called to send the XHR request carrying the target gateway identifier to the gateway plugin through the gateway. This allows the gateway plugin to retrieve the corresponding data resources from the server based on the XHR request.
[0218] In the above resource access processing method, an HTML file is received and executed, and a resource access request matching the HTML file is generated. A global interception operation is triggered based on the resource access request. Further, if it is determined that the resource access request does not carry a target gateway tag matching the gateway plugin, the target gateway tag is added to the resource access request, and the resource access request carrying the target gateway tag is forwarded to the gateway plugin deployed on the server to receive the data resource carrying the target gateway tag from the gateway plugin. This achieves global interception of resource access requests on the terminal side, and uses interception to further determine and add the target gateway tag to the resource access request, ensuring that the sent request carries the target gateway tag and can be recognized and forwarded by the gateway to further obtain the matching data resource from the server. This eliminates the need for comprehensive modification, recompilation, and repackaging of the business code in different environments on both sides of the gateway, reducing resource consumption during project development with a gateway deployed, and further improving project development efficiency.
[0219] In one embodiment, such as Figure 14 As shown, a resource access processing method is provided, referring to... Figure 14 It can be seen that the method specifically includes:
[0220] Step S1401: If a gateway configuration request is detected on the terminal, the gateway configuration information carried in the gateway configuration request is obtained, and the gateway plugin that matches the gateway configuration information is used to perform gateway configuration processing on the terminal.
[0221] Step S1402: If a resource access operation is detected on the terminal, obtain the resource access address corresponding to the resource access operation. The resource access address carries the gateway prefix.
[0222] In step S1403, the gateway plugin receives the resource access address carrying the gateway prefix sent by the terminal, clears the gateway prefix, and obtains the resource access address with the gateway prefix cleared.
[0223] In step S1404, the gateway plugin obtains the HTML file corresponding to the resource access address with the gateway prefix removed from the server, adds the gateway prefix to the HTML file, and obtains the HTML file with the gateway prefix added.
[0224] In step S1405, the terminal receives the HTML file sent by the gateway plugin, executes the HTML file, and generates a resource access request that matches the HTML file.
[0225] In step S1406, the terminal triggers a global interception operation based on the resource access request. If it is determined that the resource access request does not carry a target gateway tag that matches the gateway plugin, the target gateway tag is added to the resource access request.
[0226] In step S1407, the terminal will forward the resource access request marked by the target gateway to the gateway plugin deployed on the server.
[0227] Step S1408: If the gateway plugin determines that the request type of the resource access request is a script resource request, it determines the first gateway tag update processing method that matches the script resource request and the file storage path of the script resource file that matches the script resource request.
[0228] In step S1409, the gateway plugin adds a target gateway tag matching the gateway plugin to the file storage path based on the first gateway tag update processing method, and obtains an update script resource request.
[0229] In step S1410, the gateway plugin retrieves the script resource file that matches the update script resource request from the server based on the file storage path, converts the script resource file into a script string, and adds the target gateway tag to the script string to obtain a script string with the target gateway tag added.
[0230] In step S1411, the gateway plugin converts the script string with the target gateway tag into script cache data and outputs the script cache data as a file stream to obtain a script file stream carrying the target gateway tag.
[0231] Step S1412: If the gateway plugin determines that the request type corresponding to the resource access request is a page request, it determines the second gateway tag update processing method matching the page request and the resource access address of the page resource content matching the page request.
[0232] In step S1413, the gateway plugin adds a target gateway tag matching the gateway plugin to the resource access address according to the second gateway tag update method, and obtains an update page request.
[0233] In step S1414, the gateway plugin obtains the page resource content that matches the page request from the server based on the resource access address, and identifies the title tag from the page information resource.
[0234] In step S1415, the gateway plugin obtains the interception code associated with the cross-gateway access request, and based on the page resource content, adds the target gateway tag and the interception code after the title tag to obtain the page resource content carrying the target gateway tag.
[0235] Step S1416: If the gateway plugin determines that the request type corresponding to the resource access request is a special scenario processing request, it determines the third gateway tag update processing method matching the special scenario processing request and the additional attribute information matching the special scenario processing request.
[0236] Step S1417: If the gateway plugin determines that the special scenario processing request is located in the preset special request queue based on the additional attribute information, it obtains the storage path of the file stream that matches the special scenario processing.
[0237] In step S1418, the gateway plugin adds the target gateway tag to the storage path according to the third gateway tag update processing method, and obtains the update special scenario processing request.
[0238] In step S1419, the gateway plugin obtains a file stream from the server that matches the update special scenario processing request, and adds a target gateway tag to the file stream to obtain a file stream carrying the target gateway tag.
[0239] In step S1420, the gateway plugin sends data resources carrying the target gateway tag back to the terminal. The data resources carrying the target gateway tag include: a script file stream carrying the target gateway tag, page resource content carrying the target gateway tag, and a file stream carrying the target gateway tag.
[0240] In the above resource access processing method, the request type corresponding to the received resource access request is obtained, and the gateway tag update processing method matching the request type is determined. Then, according to the gateway tag update method matching the request type, the resource access request is processed to update the gateway tag, thus obtaining an updated resource access request. Further, the data resource matching the updated resource access request is obtained, and a target gateway tag is added to the data resource. The target gateway tag matches the gateway plugin to obtain data resources carrying the target gateway tag, and the data resources carrying the target gateway tag are then fed back. This method enables the processing of cross-gateway resource access requests through a gateway plugin deployed on the server. Furthermore, based on the gateway plugin, target gateway tags can be added to data resources during resource access processing, thereby satisfying the access rules of different environments on both sides of the gateway without requiring comprehensive modification, recompilation, and repackaging of the business code in the different environments on both sides of the gateway. This reduces resource consumption during the development of projects with gateways deployed and further improves project development efficiency.
[0241] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to 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 above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0242] Based on the same inventive concept, this application also provides a resource access processing apparatus for implementing the resource access processing method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more resource access processing apparatus embodiments provided below can be found in the limitations of the resource access processing method described above, and will not be repeated here.
[0243] In one embodiment, such as Figure 15 As shown, a resource access processing device is provided, including: a request type acquisition module 1502, a gateway tag update processing method determination module 1504, a resource access request update module 1506, a data resource acquisition module 1508, and a data resource feedback module 1510, wherein:
[0244] The request type acquisition module 1502 is used to acquire the request type corresponding to the received resource access request.
[0245] Gateway tag update processing method determination module 1504 is used to determine the gateway tag update processing method that matches the request type.
[0246] The resource access request update module 1506 is used to perform gateway tag update processing on the resource access request according to the gateway tag update method that matches the request type, so as to obtain the updated resource access request.
[0247] The data resource acquisition module 1508 is used to acquire data resources that match the update resource access request, and add a target gateway tag to the data resources to obtain data resources carrying the target gateway tag. The target gateway tag matches the gateway plugin.
[0248] The data resource feedback module 1510 is used to provide feedback on data resources carrying the target gateway tag.
[0249] In the aforementioned resource access processing device, the request type corresponding to the received resource access request is obtained, and the gateway tag update processing method matching the request type is determined. Then, based on the gateway tag update method matching the request type, the resource access request is processed to update the gateway tag, resulting in an updated resource access request. Further, data resources matching the updated resource access request are obtained, and a target gateway tag is added to the data resources. The target gateway tag matches the gateway plugin to obtain data resources carrying the target gateway tag, and the data resources carrying the target gateway tag are then fed back. This enables the processing of cross-gateway resource access requests through a gateway plugin deployed on the server. Furthermore, based on the gateway plugin, target gateway tags can be added to data resources during resource access processing, thereby satisfying the access rules of different environments on both sides of the gateway without requiring comprehensive modification, recompilation, and repackaging of the business code in the different environments on both sides of the gateway. This reduces resource consumption during the development of projects with gateways deployed and further improves project development efficiency.
[0250] In one embodiment, the resource access request update module is further configured to: if the request type of the resource access request is a script resource request, determine the first gateway tag update processing method matching the script resource request and the file storage path of the script resource file matching the script resource request; based on the first gateway tag update processing method, add the target gateway tag matching the gateway plugin to the file storage path to obtain the updated script resource request.
[0251] In one embodiment, the resource access request update module is further configured to: if the request type of the resource access request is a script resource request, obtain the resource access address that matches the script resource request; parse the information based on the resource access address to obtain the file name of the script resource file that matches the script resource request; and determine the file storage path of the script resource file that matches the script resource request based on the file name and the configuration information of the gateway plugin.
[0252] In one embodiment, the data resource acquisition module is further configured to: acquire a script resource file matching the update script resource request based on the file storage path; convert the script resource file into a script string, add the target gateway tag to the script string, and obtain a script string with the target gateway tag added; convert the script string with the target gateway tag added into script cache data, and output the script cache data in the form of a file stream, and obtain a script file stream carrying the target gateway tag.
[0253] In one embodiment, the resource access request update module is further configured to: if the request type corresponding to the resource access request is a page request, determine the second gateway tag update processing method matching the page request and the resource access address of the page resource content matching the page request; according to the second gateway tag update method, add the target gateway tag matching the gateway plugin to the resource access address to obtain the updated page request.
[0254] In one embodiment, the data resource acquisition module is further configured to: acquire page resource content matching the page request based on the resource access address; acquire the interception code associated with the cross-gateway access request; identify the title tag from the page information resource; and, based on the page resource content, add the target gateway tag and the interception code after the title tag to obtain page resource content carrying the target gateway tag.
[0255] In one embodiment, the resource access request update module is further configured to: if the request type corresponding to the resource access request is a page request, obtain the number of page requests; if the number of requests determines that the page request is a single-page request, obtain the first resource access address matching the single-page request.
[0256] In one embodiment, the resource access request update module is further configured to: if the page request is determined to be a multi-page request based on the number of requests, obtain a resource address storage array corresponding to the multi-page request; and based on the resource address storage array, match and obtain multiple second resource access addresses corresponding to the multi-page request.
[0257] In one embodiment, the resource access request update module is further configured to: if the request type corresponding to the resource access request is a special scenario processing request, determine the third gateway tag update processing method matching the special scenario processing request and the additional attribute information matching the special scenario processing request; if it is determined from the additional attribute information that the special scenario processing request is located in a preset special request queue, obtain the storage path of the file stream matching the special scenario processing; and add the target gateway tag to the storage path according to the third gateway tag update processing method to obtain the updated special scenario processing request.
[0258] In one embodiment, the data resource acquisition module is further configured to: acquire a file stream that matches the update special scenario processing request, and add a target gateway marker to the file stream to obtain a file stream carrying the target gateway marker.
[0259] In one embodiment, a resource access processing apparatus is provided, further comprising:
[0260] The resource access address receiving module is used to receive resource access addresses carrying gateway prefixes, clear the gateway prefixes, and obtain resource access addresses with cleared gateway prefixes.
[0261] The HTML file retrieval module is used to retrieve the HTML file corresponding to the resource access address excluding the gateway prefix, add the gateway prefix to the HTML file, and obtain the HTML file with the gateway prefix added.
[0262] The HTML file feedback module is used to provide feedback on HTML files with the gateway prefix added. The HTML files with the gateway prefix are used to trigger resource access requests, which carry the gateway prefix.
[0263] The resource access request receiving module is used to receive resource access requests and clear the gateway prefix carried in the resource access requests.
[0264] In one embodiment, a resource access processing apparatus is provided, further comprising a gateway configuration processing module, configured to: if a gateway configuration request is detected, obtain gateway configuration information carried in the gateway configuration request; perform gateway configuration processing on the terminal according to a gateway plugin that matches the gateway configuration information; the gateway plugin carries a gateway prefix for cross-gateway access.
[0265] In one embodiment, such as Figure 16 As shown, a resource access processing device is provided, including: a resource access request generation module 1602, an interception processing module 1604, and a data resource receiving module 1606, wherein:
[0266] The resource access request generation module 1602 is used to receive and execute an HTML file and generate a resource access request that matches the HTML file. The HTML file is obtained by the gateway plugin from the server.
[0267] The interception processing module 1604 is used to trigger a global interception operation based on the resource access request. If it is determined that the resource access request does not carry a target gateway tag that matches the gateway plugin, the target gateway tag is added to the resource access request.
[0268] The data resource receiving module 1606 is used to forward resource access requests carrying the target gateway tag to the gateway plugin deployed on the server, and to receive data resources carrying the target gateway tag from the gateway plugin.
[0269] In the aforementioned resource access processing device, an HTML file is received and executed, and a resource access request matching the HTML file is generated. A global interception operation is then triggered based on the resource access request. Further, if it is determined that the resource access request does not carry a target gateway tag matching the gateway plugin, the target gateway tag is added to the resource access request, and the resource access request carrying the target gateway tag is forwarded to the gateway plugin deployed on the server to receive the data resource carrying the target gateway tag from the gateway plugin. This achieves global interception of resource access requests on the terminal side, and uses interception to further determine and add the target gateway tag to the resource access request. This ensures that the sent request carries the target gateway tag, can be recognized and forwarded by the gateway, and can further obtain the matching data resource from the server. This eliminates the need for comprehensive modification, recompilation, and repackaging of the business code in different environments on both sides of the gateway, reducing resource consumption during project development with a gateway deployed and further improving project development efficiency.
[0270] In one embodiment, a resource access processing apparatus is provided, further comprising:
[0271] The resource access address acquisition module is used to obtain the resource access address corresponding to the resource access operation if a resource access operation is detected. The resource access address carries the gateway prefix.
[0272] The resource access address forwarding module is used to forward resource access addresses carrying gateway prefixes to the gateway plugin, clear the gateway prefix from the resource access address through the gateway plugin, and send the obtained resource access address with cleared gateway prefix to the server; wherein, the gateway plugin is used to receive the HTML file corresponding to the resource access address with cleared gateway prefix from the server, add the gateway prefix to the HTML file, and forward the HTML file with the added gateway prefix to the terminal.
[0273] In one embodiment, such as Figure 17As shown, a resource access processing system is provided, referring to... Figure 17 It can be seen that the resource access processing system includes: the browser side, the gateway, the server, and the gateway plugin deployed on the server. The resource access processing flow of the resource access processing system includes:
[0274] When a terminal detects a gateway configuration request, it obtains the gateway configuration information carried in the request and performs gateway configuration processing on the terminal based on the gateway plugin that matches the gateway configuration information. If the terminal detects a resource access operation, it obtains the resource access address (i.e., URL) corresponding to the resource access operation and forwards the resource access address carrying the resource access request to the gateway plugin through the gateway.
[0275] The gateway plugin receives a resource access address with a gateway prefix sent by the terminal, removes the gateway prefix from the resource access address, obtains the resource access address with the gateway prefix removed, sends the resource access address with the gateway prefix removed to the server, retrieves the HTML file corresponding to the resource access address with the gateway prefix removed from the server, adds the gateway prefix to the HTML file, obtains the HTML file with the gateway prefix added, and forwards the HTML file with the gateway prefix added to the terminal through the gateway.
[0276] The terminal receives an HTML file sent by the gateway plugin, executes the HTML file, generates a resource access request matching the HTML file, and sends it to the gateway plugin through the gateway. For asynchronous transmission requests, when the terminal generates a resource access request by executing the HTML file, it further triggers a global interception operation based on the resource access request. If it is determined that the resource access request does not carry a target gateway tag matching the gateway plugin, the target gateway tag is added to the resource access request. The resource access request carrying the target gateway tag is then forwarded through the gateway to the gateway plugin deployed on the server.
[0277] The gateway plugin receives resource access requests, removes the gateway prefix carried in the resource access requests, and obtains the request type corresponding to the received resource access requests to further determine the gateway tag update processing method matching the request type. Further, the gateway plugin performs gateway tag update processing on the resource access requests according to the gateway tag update method matching the request type, obtaining an updated resource access request. Then, based on the updated resource access request, the gateway prefix retrieves data resources from the server.
[0278] Furthermore, the gateway plugin adds a target gateway tag to the data resource and sends the data resource carrying the target gateway tag to the terminal through the gateway.
[0279] In the aforementioned resource access processing system, the system obtains the request type corresponding to the received resource access request and determines the gateway tag update processing method matching the request type. Then, based on the gateway tag update method matching the request type, it performs gateway tag update processing on the resource access request to obtain an updated resource access request. Further, it obtains the data resource matching the updated resource access request and adds a target gateway tag to the data resource. The target gateway tag matches the gateway plugin to obtain the data resource carrying the target gateway tag, and then returns the data resource carrying the target gateway tag. This system enables the processing of cross-gateway resource access requests through a gateway plugin deployed on the server. Furthermore, based on the gateway plugin, target gateway tags can be added to data resources during resource access processing, thus satisfying the access rules of different environments on both sides of the gateway without requiring comprehensive modification, recompilation, and repackaging of the business code in the different environments on both sides of the gateway. This reduces resource consumption during the development of projects with gateways deployed and further improves project development efficiency.
[0280] Each module in the aforementioned resource access processing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can invoke and execute the operations corresponding to each module.
[0281] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 18 As shown, the computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operating system and computer programs stored in the non-volatile storage media. The database stores data such as resource access requests, request types, gateway tag update processing methods, updated resource access requests, data resources matching the updated resource access requests, and data resources carrying target gateway tags. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When executed by the processor, the computer program implements a resource access processing method.
[0282] Those skilled in the art will understand that Figure 18The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0283] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0284] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0285] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0286] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data shall comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0287] 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 a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0288] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0289] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A resource access processing method, characterized in that, The method includes: Get the request type corresponding to the received resource access request; If the request type of the resource access request is a script resource request, obtain the resource access address that matches the script resource request, and parse the information based on the resource access address to obtain the file name of the script resource file that matches the script resource request; Based on the file name and the gateway plugin configuration information, determine the file storage path of the script resource file that matches the script resource request; Based on the first gateway tag update processing method, a target gateway tag matching the gateway plugin is added to the file storage path to obtain an update script resource request; Obtain the data resource that matches the update resource access request, and add the target gateway tag to the data resource to obtain the data resource carrying the target gateway tag; the target gateway tag matches the gateway plugin; The data resources carrying the target gateway tag are fed back.
2. The method according to claim 1, characterized in that, The step of obtaining data resources that match the updated resource access request and adding a target gateway tag to the data resources to obtain data resources carrying the target gateway tag includes: Based on the file storage path, obtain the script resource file that matches the update script resource request; The script resource file is converted into a script string, and the target gateway tag is added to the script string to obtain a script string with the target gateway tag added. The script string with the target gateway tag is converted into script cache data, and the script cache data is output as a file stream to obtain a script file stream carrying the target gateway tag.
3. The method according to claim 1, characterized in that, The step of determining the gateway tag update processing method matching the request type, and performing gateway tag update processing on the resource access request according to the gateway tag update method matching the request type to obtain an updated resource access request, includes: If the request type corresponding to the resource access request is a page request, determine the second gateway tag update processing method that matches the page request and the resource access address of the page resource content that matches the page request; According to the second gateway tag update processing method, a target gateway tag matching the gateway plugin is added to the resource access address to obtain an update page request.
4. The method according to claim 3, characterized in that, The step of obtaining data resources that match the updated resource access request and adding a target gateway tag to the data resources to obtain data resources carrying the target gateway tag includes: Based on the resource access address, obtain the page resource content that matches the page request; Retrieve the intercept code associated with the cross-gateway access request; Identify title tags from page information resources; Based on the page resource content, the target gateway tag and the interception code are added after the title tag to obtain page resource content carrying the target gateway tag.
5. The method according to claim 3, characterized in that, If the request type corresponding to the resource access request is a page request, determine the resource access address of the page resource content that matches the page request, including: If the request type corresponding to the resource access request is a page request, obtain the number of page requests; If the page request is determined to be a single-page request based on the number of requests, obtain the first resource access address that matches the single-page request. or If the page request is determined to be a multi-page request based on the number of requests, obtain the resource address storage array corresponding to the multi-page request; Based on the resource address storage array, multiple second resource access addresses corresponding to the multi-page request are obtained.
6. The method according to claim 1, characterized in that, The step of determining the gateway tag update processing method matching the request type, and performing gateway tag update processing on the resource access request according to the gateway tag update method matching the request type to obtain an updated resource access request, includes: If the request type corresponding to the resource access request is a special scenario processing request, determine the third gateway tag update processing method that matches the special scenario processing request, as well as the additional attribute information that matches the special scenario processing request. If, based on the additional attribute information, it is determined that the special scenario processing request is located in a preset special request queue, the storage path of the file stream matching the special scenario processing is obtained; According to the third gateway tag update processing method, the target gateway tag is added to the storage path to obtain the update special scenario processing request.
7. The method according to claim 1, characterized in that, The method further includes: If a gateway configuration request is detected, obtain the gateway configuration information carried in the gateway configuration request; The terminal is configured with a gateway plugin that matches the gateway configuration information; the gateway plugin carries a gateway prefix for cross-gateway access.
8. The method according to claim 1, characterized in that, The step of obtaining data resources that match the updated resource access request and adding a target gateway tag to the data resources to obtain data resources carrying the target gateway tag includes: Obtain the file stream that matches the special scenario processing request, and add the target gateway tag to the file stream to obtain the file stream carrying the target gateway tag.
9. The method according to claim 1, characterized in that, Before obtaining the request type corresponding to the received resource access request, the method further includes: Receive a resource access address carrying a gateway prefix, and clear the gateway prefix to obtain a resource access address with the gateway prefix cleared; Obtain the HTML file corresponding to the resource access address with the gateway prefix removed, and add the gateway prefix to the HTML file to obtain the HTML file with the gateway prefix added; The HTML file with the added gateway prefix is fed back; the HTML file with the added gateway prefix is used to trigger a resource access request, and the resource access request carries the gateway prefix. Receive the resource access request and clear the gateway prefix carried in the resource access request.
10. A resource access processing method, characterized in that, The method includes: The system receives and executes an HTML file, generating a resource access request matching the HTML file. The HTML file is obtained by the gateway plugin from the server. When the resource access request is a script resource request, the server, using a first gateway tag update processing method, adds a target gateway tag matching the gateway plugin to the file storage path of the script resource file matching the script resource request, thus obtaining an updated script resource request. The file storage path is determined by the server based on the file name of the script resource file matching the script resource request and the configuration information of the gateway plugin. The file name is obtained by parsing the resource access address matching the script resource request. A global interception operation is triggered based on the resource access request. If it is determined that the resource access request does not carry a target gateway tag that matches the gateway plugin, the target gateway tag is added to the resource access request. The resource access request carrying the target gateway tag is forwarded to the gateway plugin deployed on the server, and the data resource carrying the target gateway tag is received back from the gateway plugin.
11. The method according to claim 10, characterized in that, Before receiving and executing the HTML file and generating a resource access request matching the HTML file, the method further includes: If a resource access operation is detected, obtain the resource access address corresponding to the resource access operation; the resource access address carries a gateway prefix. The resource access address carrying the gateway prefix is forwarded to the gateway plugin, the gateway plugin clears the gateway prefix of the resource access address, and the obtained resource access address with the cleared gateway prefix is sent to the server. The gateway plugin is used to receive the HTML file corresponding to the resource access address with the cleared gateway prefix from the server, add a gateway prefix to the HTML file, and forward the HTML file with the added gateway prefix to the terminal.
12. A resource access processing apparatus, characterized in that, The device includes: The request type acquisition module is used to obtain the request type corresponding to the received resource access request; The gateway tag update processing method determination module is used to determine the gateway tag update processing method that matches the request type; The resource access request update module is used to: if the request type of the resource access request is a script resource request, obtain the resource access address matching the script resource request, and parse the information based on the resource access address to obtain the file name of the script resource file matching the script resource request; determine the file storage path of the script resource file matching the script resource request based on the file name and the configuration information of the gateway plugin; and add a target gateway tag matching the gateway plugin to the file storage path based on the first gateway tag update processing method to obtain the updated script resource request. The data resource acquisition module is used to acquire data resources that match the update resource access request, and add a target gateway tag to the data resources to obtain data resources carrying the target gateway tag; the target gateway tag matches the gateway plugin. The data resource feedback module is used to provide feedback on the data resources carrying the target gateway tag.
13. The apparatus according to claim 12, characterized in that, The data resource acquisition module is also used for: Based on the file storage path, obtain the script resource file that matches the update script resource request; convert the script resource file into a script string, and add the target gateway tag to the script string to obtain a script string with the target gateway tag added; The script string with the target gateway tag is converted into script cache data, and the script cache data is output as a file stream to obtain a script file stream carrying the target gateway tag.
14. The apparatus according to claim 12, characterized in that, The resource access request update module is also used for: If the request type corresponding to the resource access request is a page request, determine the second gateway tag update processing method that matches the page request and the resource access address of the page resource content that matches the page request; according to the second gateway tag update processing method, add the target gateway tag that matches the gateway plugin to the resource access address to obtain the updated page request.
15. The apparatus according to claim 14, characterized in that, The data resource acquisition module is also used for: Based on the resource access address, obtain the page resource content that matches the page request; obtain the interception code associated with the cross-gateway access request; Identify title tags from page information resources; Based on the page resource content, the target gateway tag and the interception code are added after the title tag to obtain page resource content carrying the target gateway tag.
16. The apparatus according to claim 14, characterized in that, The resource access request update module is also used for: If the request type corresponding to the resource access request is a page request, obtain the number of requests for the page request; if the number of requests determines that the page request is a single-page request, obtain the first resource access address matching the single-page request; or if the number of requests determines that the page request is a multi-page request, obtain the resource address storage array corresponding to the multi-page request. Based on the resource address storage array, multiple second resource access addresses corresponding to the multi-page request are obtained.
17. The apparatus according to claim 12, characterized in that, The resource access request update module is also used for: If the request type corresponding to the resource access request is a special scenario processing request, determine the third gateway tag update processing method matching the special scenario processing request and the additional attribute information matching the special scenario processing request; if it is determined that the special scenario processing request is located in a preset special request queue based on the additional attribute information, obtain the storage path of the file stream matching the special scenario processing. According to the third gateway tag update processing method, the target gateway tag is added to the storage path to obtain the update special scenario processing request.
18. A resource access processing apparatus, characterized in that, The device includes: The resource access request generation module is used to receive and execute an HTML file, and generate a resource access request matching the HTML file. The HTML file is obtained by the gateway plugin from the server. When the request type of the resource access request is a script resource request, the server, based on a first gateway tag update processing method, adds a target gateway tag matching the gateway plugin to the file storage path of the script resource file matching the script resource request, thus obtaining an updated script resource request. The file storage path is determined by the server based on the file name of the script resource file matching the script resource request and the configuration information of the gateway plugin. The file name is obtained by parsing the resource access address matching the script resource request. The interception processing module is used to trigger a global interception operation based on the resource access request. If it is determined that the resource access request does not carry a target gateway tag that matches the gateway plugin, the target gateway tag is added to the resource access request. The data resource receiving module is used to forward resource access requests carrying the target gateway tag to the gateway plugin deployed on the server, and to receive data resources carrying the target gateway tag from the gateway plugin.
19. The apparatus according to claim 18, characterized in that, The resource access request update module is also used for: If a resource access operation is detected, the resource access address corresponding to the resource access operation is obtained; the resource access address carries a gateway prefix; the resource access address carrying the gateway prefix is forwarded to the gateway plugin, the gateway plugin removes the gateway prefix from the resource access address, and the obtained resource access address with the gateway prefix removed is sent to the server; wherein, the gateway plugin is used to receive the HTML file corresponding to the resource access address with the gateway prefix removed from the server, add a gateway prefix to the HTML file, and forward the HTML file with the gateway prefix added to the terminal.
20. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 11.
21. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 11.
22. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Network resource access intermediary system based on resource plug-in and processing method thereof
CN112579872A