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

I want to stop forwarding of a specific request path #1237

Open
ohs30359-nobuhara opened this issue Jan 23, 2024 · 2 comments
Open

I want to stop forwarding of a specific request path #1237

ohs30359-nobuhara opened this issue Jan 23, 2024 · 2 comments

Comments

@ohs30359-nobuhara
Copy link

ohs30359-nobuhara commented Jan 23, 2024

I am currently using goreplay to forward requests to a REST API that provides the following endpoints:

  • [GET] /users/${ID}
  • [POST] /users/${ID}
  • [GET] /history/${ID}
  • [POST] /history/${ID}

My goal is to forward all requests except for the [POST] /users/${ID} endpoint. Unfortunately, the existing options --http-allow-method and --http-allow-url do not fully meet this requirement.

Is there any way to meet this requirement?

Copy link

dosubot bot commented Jan 23, 2024

🤖

Yes, you can configure GoReplay to forward all requests except for the [POST] /users/${ID} endpoint by using the --http-disallow-url option. This option allows you to specify a regular expression that matches the URLs you want to exclude from forwarding.

Here is the command you can use:

gor --input-raw :8080 --output-http staging.com --http-disallow-url "/users/.*"

This command will forward all requests except those sent to the /users/${ID} endpoint. The regular expression /users/.* matches any URL that starts with /users/ followed by any characters, effectively excluding all URLs of the form /users/${ID}.

You can find more information about request filtering in GoReplay in the Request Filtering section of the GoReplay wiki.

Also, I can confirm that the current version of GoReplay (v1.3.3) does support the --http-disallow-url option. This is evident from the HTTPModifierConfig struct in the GoReplay source code, which has a field named URLNegativeRegexp that is annotated with json:"http-disallow-url". This annotation is used for mapping the JSON configuration field http-disallow-url to the Go struct field URLNegativeRegexp.

Here is the relevant code:

type HTTPModifierConfig struct {
	URLNegativeRegexp      HTTPURLRegexp              `json:"http-disallow-url"`
	// other fields...
}

This means that when GoReplay is parsing the configuration, it will recognize the http-disallow-url option and map it to the URLNegativeRegexp field in the HTTPModifierConfig struct. You can find this in the http_modifier_settings.go file in the GoReplay repository.

I hope this helps! If you have any other questions, feel free to ask.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@ohs30359-nobuhara ohs30359-nobuhara changed the title Request for Enhancement - Improved Filtering Options I want to stop forwarding of a specific request path Jan 23, 2024
@ohs30359-nobuhara
Copy link
Author

This proposal does not meet the requirements. While control at the path level is indeed possible, it is not feasible at the method level.

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

No branches or pull requests

1 participant