Skip to content

Conversation

@huzai9527
Copy link
Contributor

No description provided.

engine := s.registerRouter()

go func() {
err := engine.Run(":" + s.option.port)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里可以直接 engine.RunListener(s.option.listener)

log.Error(err)
return
}
postData, err := route.ParseHarborwebhookPostdata(c)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

考虑下方法的入参,尽量做到通用,这里可能[]byte比较合适

}
val, ok := s.option.policies.Load(postData.Type)
if !ok {
log.Error(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不需要打印err

}

func (s *harborWebhookServer) registerRouter() *gin.Engine {
engine := gin.Default()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

整个函数体需要合理的代码块换行


func (s *harborWebhookServer) registerRouter() *gin.Engine {
engine := gin.Default()
engine.POST("/api", func(c *gin.Context) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

路由层里不要加业务逻辑代码,拆分直接传给业务层处理

@d1nfinite
Copy link
Collaborator

duplicate #116

@d1nfinite d1nfinite closed this Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants