ocpsoft / rewrite

OCPsoft URL-Rewriting Framework
http://ocpsoft.org/rewrite/
Apache License 2.0
189 stars 86 forks source link

Fix Issue #362 - Improved Spring Boot Support #375

Closed lincolnthree closed 1 year ago

lincolnthree commented 1 year ago

This is a re-opened PR continued from https://github.com/ocpsoft/rewrite/pull/368 which was targeted at the now defunct develop branch.

lincolnthree commented 1 year ago

Link with #362

larsgrefer commented 1 year ago

I think the RequestListener part is not necessary.

Spring already has an org.springframework.web.context.request.RequestContextListener and org.springframework.web.filter.RequestContextFilter which both catch the current request in a ThreadLocal which can be accessed as follows:

HttpServletRequest request = (HttpServletRequest) RequestContextHolder.currentRequestAttributes().resolveReference("request");

From there you could simply use this to get the ApplicationContext:

RequestContextUtils.findWebApplicationContext(request);
lincolnthree commented 1 year ago

Merged into all relevant branches! Thanks everyone for your patience.