Skip to content

Add support for customizing WebJars resource handler path pattern #31769

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

Closed
wants to merge 1 commit into from

Conversation

vpavic
Copy link
Contributor

@vpavic vpavic commented Jul 15, 2022

At present, both Spring MVC and Spring WebFlux auto-configurations hardcode path pattern for WebJars resource handlers to /webjars/** which means users are unable to change the path.

This commit introduces spring.mvc.webjars-path-pattern and spring.webflux.webjars-path-pattern configuration properties that allow customization of WebJars resource handler path pattern.


The background of the proposal is that using /webjars/** in path is somewhat leaky as it tells details about the tech stack. For that reason I usually prefer mapping WebJars to a more generic path, like /assets/**. Ideally, the default should also be a generic one but I'm not sure if that's a welcome change so it's probably one of the topics for team to discuss.

At present, both Spring MVC and Spring WebFlux auto-configurations hardcode path pattern for WebJars resource handlers to "/webjars/**" which means users are unable to change the path.

This commit introduces "spring.mvc.webjars-path-pattern" and "spring.webflux.webjars-path-pattern" configuration properties that allow customization of WebJars resource handler path pattern.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 15, 2022
@philwebb philwebb added type: enhancement A general enhancement for: team-meeting An issue we'd like to discuss as a team to make progress and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 18, 2022
@philwebb philwebb added this to the 3.0.x milestone Jul 18, 2022
@philwebb philwebb removed the for: team-meeting An issue we'd like to discuss as a team to make progress label Aug 22, 2022
@snicoll snicoll modified the milestones: 3.0.x, 3.0.0-M5 Sep 7, 2022
@snicoll snicoll self-assigned this Sep 7, 2022
snicoll pushed a commit that referenced this pull request Sep 7, 2022
At present, both Spring MVC and Spring WebFlux auto-configurations
hardcode the path pattern for WebJars resource handlers to
"/webjars/**", which means users are unable to change the path.

This commit introduces "spring.mvc.webjars-path-pattern" and
"spring.webflux.webjars-path-pattern" configuration properties that
allow customization of WebJars resource handler path pattern.

See gh-31769
@snicoll snicoll closed this in d546ea5 Sep 7, 2022
@vpavic vpavic deleted the webjars-path-pattern branch September 7, 2022 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants