Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect service requests to another server

I've created a filter so that I can intercept all controller actions and forward the request to a different server. I need to temporarily redirect based on user-agent.

So I have the following in http://www.mysite1.com

class DealsFilters {

    def filters = {
    all(controller: '*', action: '*') {
        before = {
                if (someConditionHere)
                {
                    redirect(url:"http://www.mysite2/")
                    return
                }               
        }
    }       
}

What I am wondering is will the request and all it params be correctly passed to mysite2?
i.e. mysite1 acts as a service and receives requests to get user data, update deals, add new users, etc...

mysite2 is a new version of mysite1 (mysite1 will be decommisioned after mysite2 has been tested).

Is it as simple as a redirect?

Thanks

like image 624
Thomas Buckley Avatar asked Dec 29 '25 03:12

Thomas Buckley


1 Answers

I'm using grails 1.3.7 as pointed out to lucke84 (I should have stated this in original question).

Found following link gave me most of the answer:
Best practice for redirecting from one web domain to another in Grails?

redirect(url:"http://localhost:8080${request.forwardURI}?${request.queryString}",params:params)
like image 66
Thomas Buckley Avatar answered Jan 01 '26 08:01

Thomas Buckley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!