Skip to content

Inability to redirect from a POST to a GET #229

Description

@syntaqx
func getHandler(c *echo.Context) error {
    return c.String("Hello world")
}

func postHandler(c *echo.Context) error {
    return echo.Redirect(http.StatusTemporaryRedirect, "/")
}

func main() {
    e := echo.New()

    e.Get("/", getHandler)
    e.Post("/post", postHandler)

    e.Run(":8080")
}

I whipped up that example pretty quickly, so I'm not entirely sure it works PERFECT, but the case that it makes hold true. For situations where you would want to redirect from a POST to a GET (for example, POST to a login form, and then redirect them back to the index), echo.Redirect fails. The redirect actually redirects to POST / instead of the expected GET /

I found some resources regarding this in Go that were solved in 2012, but has been resolved for some time. I'm assuming this might be within echo instead of Go's HTTP layer directly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions