Repository navigation
web: serve all requests from Flamego and remove Macaron - #8542
Merged
Merged
Conversation
3 of 4 tasks
| // Matches go-macaron's Redis adapters: any non-empty `tls=` value enables | ||
| // TLS with InsecureSkipVerify. | ||
| config.Options.TLSConfig = &tls.Config{InsecureSkipVerify: true} | ||
| opts.tlsConfig = &tls.Config{InsecureSkipVerify: true} |
Comment on lines
+306
to
+310
| http.SetCookie(w, &http.Cookie{ | ||
| Name: conf.Security.LoginStatusCookieName, | ||
| Value: "true", | ||
| Path: cmp.Or(conf.Server.Subpath, "/"), | ||
| }) |
Comment on lines
+306
to
+310
| http.SetCookie(w, &http.Cookie{ | ||
| Name: conf.Security.LoginStatusCookieName, | ||
| Value: "true", | ||
| Path: cmp.Or(conf.Server.Subpath, "/"), | ||
| }) |
Comment on lines
+519
to
+525
| http.SetCookie(w, &http.Cookie{ | ||
| Name: conf.Session.CookieName, | ||
| Path: cmp.Or(conf.Server.Subpath, "/"), | ||
| HttpOnly: true, | ||
| Expires: time.Now(), | ||
| MaxAge: -1, | ||
| }) |
Comment on lines
+100
to
+105
| http.SetCookie(c.ResponseWriter(), &http.Cookie{ | ||
| Name: "lang", | ||
| Value: url.QueryEscape(lang), | ||
| Path: "/" + strings.TrimPrefix(subURL, "/"), | ||
| MaxAge: 1<<31 - 1, | ||
| }) |
unknwon
force-pushed
the
flamego-server
branch
2 times, most recently
from
November 14, 2026 05:43
6c144ea to
9131558
Compare
unknwon
force-pushed
the
flamego-server
branch
from
November 14, 2026 07:09
9131558 to
19ad4c2
Compare
unknwon
force-pushed
the
flamego-server
branch
from
November 14, 2026 07:11
19ad4c2 to
487ac81
Compare
unknwon
force-pushed
the
flamego-server
branch
2 times, most recently
from
November 14, 2026 16:03
34ec33f to
a53bf7b
Compare
unknwon
force-pushed
the
flamego-server
branch
3 times, most recently
from
November 14, 2026 18:49
1592054 to
5a2664f
Compare
unknwon
force-pushed
the
flamego-server
branch
from
November 14, 2026 19:00
5a2664f to
c87d20f
Compare
unknwon
force-pushed
the
flamego-server
branch
from
November 14, 2026 19:23
c87d20f to
d56e08a
Compare
unknwon
force-pushed
the
flamego-server
branch
from
November 14, 2026 19:40
d56e08a to
93acaf1
Compare
unknwon
force-pushed
the
flamego-server
branch
7 times, most recently
from
November 14, 2026 23:00
f6f30f5 to
a7abd1e
Compare
This was referenced Nov 16, 2026
Merged
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
unknwon
marked this pull request as ready for review
November 17, 2026 07:06
unknwon
force-pushed
the
flamego-server
branch
from
November 17, 2026 08:00
51f4180 to
411bf76
Compare
unknwon
added a commit
that referenced
this pull request
Nov 17, 2026
unknwon
force-pushed
the
flamego-server
branch
from
November 17, 2026 13:32
411bf76 to
50826ff
Compare
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the pull request
Part 3 of 3 of removing Macaron: Flamego now serves every request, and
gopkg.in/macaron.v1and allgithub.com/go-macaron/*modules are removed fromgo.mod.newRoutingHandleris the top-level handler. It runs the request logger, recovery, thenosniffandX-Frame-Optionsheaders, the static files (custompublic, embeddedpublic, user and repository avatars), the localizer and the cache, then the routes. It takes the localizer, the session middleware and the authenticator as arguments, so the access tests supply the viewer without a database. Gzip ([server] ENABLE_GZIP) wraps it withklauspost/compress/gzhttp, and the fcgi subpath is trimmed in aBeforehook./healthcheck,/-/metrics, Git over HTTP and LFS are mounted before the session middleware, so they still never create a session. Every other route runs the cross-origin protection,session.Sessioner,authenticator(the same session, token, reverse proxy and basic authentication as before), the CORS headers and the captcha.flamego/sessionwith the memory, file and Redis providers from[session]. It saves a session only when the request changed it, like Macaron's session did, and refreshes the expiry of a session that is only read.apiV1Bridger, which now takes the user, the authentication method and the locale from Flamego.apiV1Accessreplaces theTogglemiddleware for API v1 with the same responses. Unknown API v1 routes and server errors still render the 404 and 500 pages of the web app.go-macaron/binding, for the rules its requests use (Required,AlphaDashDot,Email,Size,MaxSize,In,OmitEmpty). Binding errors keep the same JSON fields, classifications and status codes (400, 415 and 422).internal/i18nreplacesgo-macaron/i18nwith the same language choice: thelangquery parameter (remembered in a cookie, then redirected), thelangcookie, thenAccept-Language.context.Contexter,context.Toggle,context.Context,flamegoBridger,flamegoInjector,flamegoSessionAdapter, the Macaron renderer,internal/form/form.go(the go-macaron binding rules) andinternal/mocks/locale.go. Mail takes the locale instead of*macaron.Context.flamego/session, and the route coverage check lists Flamego routes only.Fixes #7503
Fixes #7562
Behavior changes from legacy
prefixoption of the Redis session provider is not supported byflamego/session. It is ignored with a warning, so with a prefix configured, users sign in again after the upgrade.Screenshots
No UI changes. Pages after this change, served by a
-tags prodbuild:?lang=zh-CNChecklist
Test plan
go test ./cmd/... ./internal/...passes andmoon run gogs:lintreports 0 issues. The access tests of the web API run through the whole routing handler, session middleware included. The session fixation test runs onflamego/sessionwith the memory and file providers.-shuffle=on, including the check that every route has a test: Git over HTTP and SSH, Git LFS with thegit lfsclient, the web API and API v1.go-macaron/bindingon 990 values across all 15 request types: the JSON of the errors is the same for every value. MakingMaxSizeinclusive, skippingAlphaDashDotor changing a message each made the comparison fail.-tags prodbuild: signing in through the form changes the session ID and the old ID is not signed in, signing out expires the cookie and the old ID gets 401, and an anonymous visitor gets one session cookie, not one per request.?lang=zh-CNsets the cookie and redirects to the same path. WithENABLE_GZIP = true, assets are compressed. Cross-site POSTs to the web API get 403, andnosniffandX-Frame-Optionsare set.