handle(request, response, cursor = 0) {
        // Do not handle the request if the response has been sent aka. the request is no longer active
        if (response.completed) return;

        // Retrieve the middleware for the current cursor, track the cursor if there is a valid middleware
        let iterator;
        const middleware = this.options.middlewares[cursor];
        if (middleware) {
            // Determine if this middleware requires path matching
            if (middleware.match) {
                // Check if the middleware pattern matches that starting of the request path
                if (request.path.startsWith(middleware.pattern)) {
                    // Ensure that the character after the middleware pattern is either a trailing slash or out of bounds of string
                    const trailing = request.path[middleware.pattern.length];
                    if (trailing !== '/' && trailing !== undefined) {
                        // This handles cases where "/docs" middleware will incorrectly match "/docs-JSON" for example
                        return this.handle(request, response, cursor + 1);
                    }
                } else {
                    // Since the middleware pattern does not match the start of the request path, skip this middleware
                    return this.handle(request, response, cursor + 1);
                }
            }

            // Track the middleware cursor to prevent double execution
            response._track_middleware_cursor(cursor);

            // Initialize the iterator for this middleware
            iterator = (error) => {
                // If an error occured, pipe it to the error handler
                if (error instanceof Error) return response.throw(error);

                // Handle this request again with an incremented cursor to execute the next middleware or route handler
                this.handle(request, response, cursor + 1);
            };
        }

        // Determine if this is an async handler which can explicitly throw uncaught errors
        const is_async_handler = (middleware ? middleware.handler : this.handler).constructor.name === 'AsyncFunction';
        if (is_async_handler) {
            // Execute the middleware or route handler within a promise to catch and pipe synchronous errors
            new Promise(async (resolve) => {
                try {
                    if (middleware) {
                        // Execute the middleware or route handler with the iterator
                        await middleware.handler(request, response, iterator);

                        // Call the iterator anyways in case the middleware never calls the next() iterator
                        iterator();
                    } else {
                        await this.handler(request, response);
                    }
                } catch (error) {
                    // Catch and pipe any errors to the error handler
                    response.throw(error);
                }

                // Resolve promise to ensure it is properly cleaned up from memory
                resolve();
            });
        } else {
            // Execute the middleware or route handler within a protected try/catch to catch and pipe synchronous errors
            try {
                let output;
                if (middleware) {
                    output = middleware.handler(request, response, iterator);
                } else {
                    output = this.handler(request, response);
                }

                // Determine if a Promise instance was returned by the handler
                if (typeof output?.then === 'function') {
                    // If this is a middleware, we must try to call iterator after returned promise resolves
                    if (middleware) output.then(iterator);

                    // Catch and pipe any errors to the global error handler
                    output.catch((error) => response.throw(error));
                }
            } catch (error) {
                // Catch and pipe any errors to the error handler
                response.throw(error);
            }
        }
    }
Handles an incoming request through this route.

@param {import('../http/Request.js')} request The HyperExpress request object.
@param {import('../http/Response.js')} response The HyperExpress response object.
@param {Number=} cursor The middleware cursor.