spring-cloud / spring-cloud/spring-cloud-gateway

Is the tokenizeToStringArray's delimiters in FilterDefinition or PredicateDefinition can configurable?

Open
#621 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
4.9k
Forks
3.5k
Avg merge
20h 57m
Merged PRs (30d)
8

Description

/**
 * @author Spencer Gibb
 */
@Validated
public class FilterDefinition {
	@NotNull
	private String name;
	private Map<String, String> args = new LinkedHashMap<>();

	public FilterDefinition() {
	}

	public FilterDefinition(String text) {
		int eqIdx = text.indexOf("=");
		if (eqIdx <= 0) {
			setName(text);
			return;
		}
		setName(text.substring(0, eqIdx));

		String[] args = tokenizeToStringArray(text.substring(eqIdx+1), ",");

		for (int i=0; i < args.length; i++) {
			this.args.put(NameUtils.generateName(i), args[i]);
		}
	}

	...
}

String[] args = tokenizeToStringArray(text.substring(eqIdx+1), ",");

is the tokenizeToStringArray's delimiters can configurable?

For example, I customized a CustomFilter whose config, a parameter template, is in JSON format if I configure it as follows.

...
Filters:

- CustomFilter={"name": "XXX", "age": 111}

Then spring cloud gateway will assign template {"name": "XXX" only). How can I solve this problem? Can you support configuring tokenizeToStringArray's delimiters to be a symbol or other symbols?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the FilterDefinition constructor and its tokenizeToStringArray call, then compare the related PredicateDefinition parsing mentioned in the issue. Reproduce the CustomFilter JSON example and determine how delimiter configuration should preserve the full parameter value; done means the configured filter arguments retain the JSON content correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.