Skip to content

Redirect for subrouters #999

@shamilovstas

Description

@shamilovstas

Commented here, but since the issue cannot be reopened, I opened this issue to continue the discussion.

Copy of my comment there:

I'm not sure whether my question relates to the initial question, but perhaps it makes sense when subrouters are used? Consider this:

router.Route("/{username}", func(r chi.Router) {
	r.Get("/", func(w http.ResponseWriter, request *http.Request) {
		// r.Redirect("/details")  <---- This is where I want to redirect to, keeping the subrouter's prefix (/{username}).
	})

	r.Get("/details", func(writer http.ResponseWriter, request *http.Request) {
		// ...                     <---- Redirects here
	})
} 

Originally posted by @shamilovstas in #709

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions