gofr icon indicating copy to clipboard operation
gofr copied to clipboard

En/http redirects

Open Umang01-hash opened this issue 8 months ago • 3 comments

Pull Request Template

Description:

  • Resolves #1531

Example:

package main

import (
	"gofr.dev/pkg/gofr"

	"gofr.dev/pkg/gofr/http/response"
)

func main() {
	app := gofr.New()

	app.GET("/old-page", func(ctx *gofr.Context) (any, error) {
		// Redirect to a new URL 
		return response.Redirect{URL: "https://example.com/new-page"}, nil
	})

	app.Run()
}

Screenshot 2025-04-10 at 1 15 45 PM

Additional Information:

  • Mention any relevant dependencies or external libraries used.
  • Include screenshots or code snippets (if necessary) to clarify the changes.

Checklist:

  • [x] I have formatted my code using goimport and golangci-lint.
  • [x] All new code is covered by unit tests.
  • [x] This PR does not decrease the overall code coverage.
  • [x] I have reviewed the code comments and documentation for clarity.

Thank you for your contribution!

Umang01-hash avatar Apr 10 '25 07:04 Umang01-hash

@Umang01-hash , Can we also check and add tests for url with path and query params as well as request Bodies, headers etc.....get handled successfully through the redirect. I feel that is not the case right now.

coolwednesday avatar Apr 10 '25 10:04 coolwednesday

@Umang01-hash , Can we also check and add tests for url with path and query params as well as request Bodies, headers etc.....get handled successfully through the redirect. I feel that is not the case right now.

@Umang01-hash, Can we add test for these cases ? I feel this implementation can fall short in fitting these usecases.

coolwednesday avatar Apr 16 '25 04:04 coolwednesday