Sounthar Shanmugam
Sounthar Shanmugam

Reputation: 21

Beego Redirect with Post method

I want to redirect the url using the POST method.

The code is usually using this.Redirect("/", 302).

This time, I want something like post url which should redirect to that page.

Is this possible with Beego?

Thanks.

Upvotes: 1

Views: 1108

Answers (1)

Marc
Marc

Reputation: 21145

Beego's Redirect takes a http code, you're just using the wrong one. You want 307 to force the request method to be the same as the original one.

this.Redirect("/", 307)

Most clients and browsers issue a GET on the 302 target, which was actually contrary to the RFC.

Due to this, 303 and 307 were introduced:

  • 303: clients must use a GET request
  • 307: clients must use the original method (eg: POST if a POST was originally used)

Upvotes: 4

Related Questions