0

I am a writing a middleware program, where it internally calls third party api. The third party api responds with 301 including some headers. I have respond with response i got to front end. Is there any piece of code sample which will do this?

TobiSH
  • 2,833
  • 3
  • 23
  • 33
ACB
  • 11
  • 3

1 Answers1

0

In this case, I do not see other options rather than building the response object setting the headers.

public Result proxy() {
  response().setHeader(myHeader, headerValue1);
  // all your custom headers
  return status(Http.Status.MOVED_PERMANENTLY, "response body").as(your media type);
}
pedrohreis
  • 1,030
  • 2
  • 14
  • 33
  • But this wont redirect the consumer with the redirect url i got it from my wsclient 301 response – ACB Nov 01 '19 at 21:17
  • sorry, but why not? As long as you're passing `location` header and indicating with `301` as response code, your client should be able to follow the redirect. – pedrohreis Nov 02 '19 at 17:34