I have a Spring Boot & Spring Security application running, which should now get multi tenancy support.
I'd like to keep things as simple as possible. Though I'd like to determine the the database by path variable or request parameter. (the Apache Web Server in front of the Spring Boot app will handle that, i.e. it maps from subdomain to either path variable or request parameter).
Now I need a way to grab the first path variable (or a specific request param) before Spring calls the controller, and of course the value must be stored somewhere, so I can access it when I need to choose the right database.
So either (depending on what's possible / easier)
http://localhost:8080/customer1
(which I'd prefer) orhttp://localhost:8080?_customer=customer1
should simply call the @Controller
with @RequestMapping("")
and the value customer1
should be stored somewhere for that request.
I know that 2.
might be simpler, because it will already hit the right @Controller
, but I'd prefer 1.
somehow.
Thank you!
EDIT:
I just recognized, that HandlerInterceptor
doesn't work as expected, because Spring Security always handles the requests first. Though I need an Interceptor that handles it before Spring Security kicks in.