-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: experiment to convert macaron to gin #7177
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7177 +/- ##
=========================================
Coverage ? 41.73%
=========================================
Files ? 450
Lines ? 61143
Branches ? 0
=========================================
Hits ? 25519
Misses ? 32307
Partials ? 3317
Continue to review full report at Codecov.
|
routers/routes/gin_bridge.go
Outdated
|
||
// for health check | ||
g.HEAD("/", func(c *gin.Context) { | ||
c.String(200, "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c.AbortWithStatus(http.StatusOK)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
e586b73
to
17f70b2
Compare
routers/routes/gin.go
Outdated
func SignedUserName(ctx *gin.Context) string { | ||
if v, ok := ctx.Get("SignedUserName"); !ok { | ||
return "" | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kolaente golangci-lint failed because
routers/routes/gin.go:35:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (golint)
--
583 | } else {
584 | ^
585 | Makefile:471: recipe for target 'golangci-lint' failed
But I don't think there is another better style. :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about something like
var uname string
if v, ok := ctx.Get("SignedUserName"); ok {
uname = v.(string)
}
return uname
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lunny Exactly what @jolheiser meant is needed here.
@zeripath I think your suggest is not right. |
Oh I see. Switch em round? |
So func SignedUserName(ctx *gin.Context) string {
if v, ok := ctx.Get("SignedUserName"); ok {
return v.(string)
}
return ""
} |
cfebfaa
to
57d0301
Compare
Can you provide some info why gin and not chi ? |
Thank you |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 months. Thank you for your contributions. |
related with #7403 |
Closed by #7420 |
This PR is an experiment to convert macaron to gin.
It moved all static files from macaron's middleware to gin's.
It made macaron as a middleware of gin, so that we can keep most of routes and move step by step.