Skip to content

How to Perform Redirects in Gofr? #1531

Open
@ibadi-id

Description

@ibadi-id

I am trying to redirect users to a frontend URL after authentication in Gofr. However, I couldn't find a built-in Redirect method in ctx.

Here’s my current code:

app.GET("/auth/google/callback", func(ctx *gofr.Context) (interface{}, error) {
	sessionManager := session.GetSession()

	email := sessionManager.GetString(ctx.Context, "email")
	name := sessionManager.GetString(ctx.Context, "name")

	// Expected to redirect but ctx does not have a Redirect method
	frontendURL := fmt.Sprintf("https://frontend.com/dashboard?email=%s&name=%s", email, name)

	// What is the correct way to redirect?
	ctx.Redirect(frontendURL, http.StatusFound) // This does not exist in Gofr

	return nil, nil
})

Expected Behavior
A way to redirect users to the frontend URL after authentication.

Actual Behavior
ctx.Redirect() does not exist in Gofr. like in echo or Fiber
There is no clear documentation on how to handle redirects.

Questions
What is the correct way to redirect users in Gofr?
Is there an alternative method to set the Location header?

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions