Context
livetemplate#434 is fixed (PR livetemplate#443, merged): ctx.Redirect now accepts relative references, so a recipe mounted behind http.StripPrefix can redirect back to its own mount via ctx.Redirect("", http.StatusSeeOther) — the browser resolves the relative Location against the full, un-stripped URL.
This makes the mountPath workaround in docs#34 unnecessary.
What to remove
The login recipe currently threads a mount path through the handler constructor purely so it can build an absolute redirect target:
examples/login/handler.go — func Handler(mountPath string, opts ...livetemplate.Option) http.Handler → drop the mountPath parameter.
examples/login/controller.go — the mountPath string field on AuthController and the two ctx.Redirect(c.mountPath, http.StatusSeeOther) call sites (Login/Logout) → replace with ctx.Redirect("", http.StatusSeeOther).
examples/login/cmd/main.go — the call site passing mountPath into loginrecipe.Handler(mountPath, opts...) → drop the argument (keep the http.StripPrefix mount as-is).
Constraints / acceptance
- Mount with a trailing slash. The empty-string "reload self" form resolves to
./ (current directory), so it relies on the canonical trailing-slash mount http.StripPrefix("/apps/login/", …) — which the recipe already uses. (See the livetemplate Redirect godoc / docs/references/authentication.md note.)
- Requires a livetemplate dependency bump to the release that includes #443 (next tag after the current one).
e2e/login TestLogin_E2E_SubpathMount must still pass: successful login lands at <serverURL>/apps/login/ (not the domain root), and logout returns there too. This is the browser-side validation that the relative redirect resolves correctly.
Ref: livetemplate#434, livetemplate#443, docs#34.
Context
livetemplate#434 is fixed (PR livetemplate#443, merged):
ctx.Redirectnow accepts relative references, so a recipe mounted behindhttp.StripPrefixcan redirect back to its own mount viactx.Redirect("", http.StatusSeeOther)— the browser resolves the relativeLocationagainst the full, un-stripped URL.This makes the
mountPathworkaround in docs#34 unnecessary.What to remove
The login recipe currently threads a mount path through the handler constructor purely so it can build an absolute redirect target:
examples/login/handler.go—func Handler(mountPath string, opts ...livetemplate.Option) http.Handler→ drop themountPathparameter.examples/login/controller.go— themountPath stringfield onAuthControllerand the twoctx.Redirect(c.mountPath, http.StatusSeeOther)call sites (Login/Logout) → replace withctx.Redirect("", http.StatusSeeOther).examples/login/cmd/main.go— the call site passingmountPathintologinrecipe.Handler(mountPath, opts...)→ drop the argument (keep thehttp.StripPrefixmount as-is).Constraints / acceptance
./(current directory), so it relies on the canonical trailing-slash mounthttp.StripPrefix("/apps/login/", …)— which the recipe already uses. (See the livetemplateRedirectgodoc /docs/references/authentication.mdnote.)e2e/loginTestLogin_E2E_SubpathMountmust still pass: successful login lands at<serverURL>/apps/login/(not the domain root), and logout returns there too. This is the browser-side validation that the relative redirect resolves correctly.Ref: livetemplate#434, livetemplate#443, docs#34.