Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hooks on forwarded requests #515

Open
mcweba opened this issue Jun 7, 2023 · 1 comment
Open

Hooks on forwarded requests #515

mcweba opened this issue Jun 7, 2023 · 1 comment
Assignees

Comments

@mcweba
Copy link
Collaborator

mcweba commented Jun 7, 2023

Consider the following routing rules:

{
	"/gateleen/resources/v1/(.*)": {
		"path": "/gateleen/other/resources/v1/$1"
	},
	"/gateleen/other/resources/v1/(.*)": {
		"path": "/gateleen/somewhere/else/$1"
	}
}

A master routing rule (/gateleen/resources/v1/(.*) which forwards to another rule (/gateleen/other/resources/v1/(.*)).

When hooks for both URLs are created, the second hook (to /gateleen/other/resources/v1/(.*)) will never be triggered because of the x-hooked request header added by the HookHandler class.

The HookHandler checks whether a request is already hooked with

/**
 * Checks if the original Request was already hooked.
 * Eg. After a request is processed by the hook handler
 * (register), the handler creates a self request with
 * a copy of the original request. Therefore it's
 * necessary to mark the request as already hooked.
 *
 * @param request request
 * @return true if the original request was already hooked.
 */
public boolean isRequestAlreadyHooked(HttpServerRequest request) {
	String hooked = request.headers().get(HOOKED_HEADER);
	return hooked != null && hooked.equals("true");
}

When forwarding a request, the original request headers are copied to the new client request. I am not sure whether we should also copy the x-hooked request header.

@ljucam I assigned it to you, since you are the master of the hooks :-)

@mushtaq96
Copy link

Hello @mcweba is this issue still open and require any help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants