|
|
@ -70,13 +70,26 @@ func RegisterWebCoreServant(e *gin.Engine, s WebCore, b WebCoreBinding, r WebCor
|
|
|
|
|
|
|
|
|
|
|
|
// register routes info to router
|
|
|
|
// register routes info to router
|
|
|
|
router.Handle("POST", "/user/logout/", func(c *gin.Context) {
|
|
|
|
router.Handle("POST", "/user/logout/", func(c *gin.Context) {
|
|
|
|
|
|
|
|
select {
|
|
|
|
|
|
|
|
case <-c.Request.Context().Done():
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
r.RenderLogout(c, s.Logout())
|
|
|
|
r.RenderLogout(c, s.Logout())
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
router.Handle("POST", "/user/login/", func(c *gin.Context) {
|
|
|
|
router.Handle("POST", "/user/login/", func(c *gin.Context) {
|
|
|
|
|
|
|
|
select {
|
|
|
|
|
|
|
|
case <-c.Request.Context().Done():
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
req, err := b.BindLogin(c)
|
|
|
|
req, err := b.BindLogin(c)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
r.RenderLogin(c, nil, err)
|
|
|
|
r.RenderLogin(c, nil, err)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
resp, err := s.Login(req)
|
|
|
|
resp, err := s.Login(req)
|
|
|
|
r.RenderLogin(c, resp, err)
|
|
|
|
r.RenderLogin(c, resp, err)
|
|
|
@ -84,6 +97,12 @@ func RegisterWebCoreServant(e *gin.Engine, s WebCore, b WebCoreBinding, r WebCor
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
h := func(c *gin.Context) {
|
|
|
|
h := func(c *gin.Context) {
|
|
|
|
|
|
|
|
select {
|
|
|
|
|
|
|
|
case <-c.Request.Context().Done():
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
r.RenderArticles(c, s.Articles())
|
|
|
|
r.RenderArticles(c, s.Articles())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
router.Handle("HEAD", "/articles/:category/", h)
|
|
|
|
router.Handle("HEAD", "/articles/:category/", h)
|
|
|
@ -91,6 +110,12 @@ func RegisterWebCoreServant(e *gin.Engine, s WebCore, b WebCoreBinding, r WebCor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
router.Handle("GET", "/index/", func(c *gin.Context) {
|
|
|
|
router.Handle("GET", "/index/", func(c *gin.Context) {
|
|
|
|
|
|
|
|
select {
|
|
|
|
|
|
|
|
case <-c.Request.Context().Done():
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
r.RenderIndex(c, s.Index())
|
|
|
|
r.RenderIndex(c, s.Index())
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|