go-chi / go-chi/chi

Redirect for subrouters

Open
#999 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
22.8k
Forks
1.2k
Avg merge
5h 17m
Merged PRs (30d)
10

Description

Commented [here](https://github.com/go-chi/chi/issues/709), 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](https://github.com/go-chi/chi/issues/709#issuecomment-2888496580)_

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the linked issue #709 and the shown router.Route and r.Get entry points; no source file or test is named in this issue. Define whether a redirect API should preserve the subrouter prefix, and consider the request complete only when that behavior is specified and covered by an agreed implementation and test.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.