diff --git a/go.mod b/go.mod index e826578e..80d99a7f 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/Masterminds/semver/v3 v3.1.1 github.com/afocus/captcha v0.0.0-20191010092841-4bd1f21c8868 github.com/alimy/cfg v0.1.0 - github.com/alimy/mir/v3 v3.0.0-alpha.5 + github.com/alimy/mir/v3 v3.0.0-alpha.6 github.com/aliyun/aliyun-oss-go-sdk v2.2.2+incompatible github.com/allegro/bigcache/v3 v3.0.2 github.com/bytedance/sonic v1.5.0 diff --git a/go.sum b/go.sum index df94f30e..dee0dc5e 100644 --- a/go.sum +++ b/go.sum @@ -144,8 +144,8 @@ github.com/alexflint/go-filemutex v0.0.0-20171022225611-72bdc8eae2ae/go.mod h1:C github.com/alexflint/go-filemutex v1.1.0/go.mod h1:7P4iRhttt/nUvUOrYIhcpMzv2G6CY9UnI16Z+UJqRyk= github.com/alimy/cfg v0.1.0 h1:J7KDLEoVIjEBMGlQJb2ljad/d49gJ4Tsl2ogZ9XNhaY= github.com/alimy/cfg v0.1.0/go.mod h1:rOxbasTH2srl6StAjNF5Vyi8bfrdkl3fLGmOYtSw81c= -github.com/alimy/mir/v3 v3.0.0-alpha.5 h1:KFv8ulmC1hDPDezh/dQ+ZwZwmmwrcWUV4TZJrMBZB8I= -github.com/alimy/mir/v3 v3.0.0-alpha.5/go.mod h1:ybhT2ijOiDn0lLwWzIY6vXdv+uzZrctS7VFfczcXBWU= +github.com/alimy/mir/v3 v3.0.0-alpha.6 h1:4xcyE12MgzTbcIcYtnt3ILrVrxFjI71qhqh0JL2gB58= +github.com/alimy/mir/v3 v3.0.0-alpha.6/go.mod h1:ybhT2ijOiDn0lLwWzIY6vXdv+uzZrctS7VFfczcXBWU= github.com/aliyun/aliyun-oss-go-sdk v2.2.2+incompatible h1:9gWa46nstkJ9miBReJcN8Gq34cBFbzSpQZVVT9N09TM= github.com/aliyun/aliyun-oss-go-sdk v2.2.2+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= diff --git a/internal/mirc/auto/api/m/v1/user.go b/internal/mirc/auto/api/m/v1/user.go index b31984b9..431343e7 100644 --- a/internal/mirc/auto/api/m/v1/user.go +++ b/internal/mirc/auto/api/m/v1/user.go @@ -66,13 +66,26 @@ func RegisterUserServant(e *gin.Engine, s User, b UserBinding, r UserRender) { // register routes info to router router.Handle("POST", "/user/logout/", func(c *gin.Context) { + select { + case <-c.Request.Context().Done(): + return + default: + } + r.RenderLogout(c, s.Logout()) }) router.Handle("POST", "/user/login/", func(c *gin.Context) { + select { + case <-c.Request.Context().Done(): + return + default: + } + req, err := b.BindLogin(c) if err != nil { r.RenderLogin(c, nil, err) + return } resp, err := s.Login(req) r.RenderLogin(c, resp, err) diff --git a/internal/mirc/auto/api/r/v1/user.go b/internal/mirc/auto/api/r/v1/user.go index 55961d75..1850b157 100644 --- a/internal/mirc/auto/api/r/v1/user.go +++ b/internal/mirc/auto/api/r/v1/user.go @@ -66,13 +66,26 @@ func RegisterUserServant(e *gin.Engine, s User, b UserBinding, r UserRender) { // register routes info to router router.Handle("POST", "/user/logout/", func(c *gin.Context) { + select { + case <-c.Request.Context().Done(): + return + default: + } + r.RenderLogout(c, s.Logout()) }) router.Handle("POST", "/user/login/", func(c *gin.Context) { + select { + case <-c.Request.Context().Done(): + return + default: + } + req, err := b.BindLogin(c) if err != nil { r.RenderLogin(c, nil, err) + return } resp, err := s.Login(req) r.RenderLogin(c, resp, err) diff --git a/internal/mirc/auto/api/s/v1/user.go b/internal/mirc/auto/api/s/v1/user.go index a14c1e42..ef2c855b 100644 --- a/internal/mirc/auto/api/s/v1/user.go +++ b/internal/mirc/auto/api/s/v1/user.go @@ -62,19 +62,38 @@ func RegisterUserServant(e *gin.Engine, s User, b UserBinding, r UserRender) { // register routes info to router router.Handle("POST", "/user/logout/", func(c *gin.Context) { + select { + case <-c.Request.Context().Done(): + return + default: + } + r.RenderLogout(c, s.Logout()) }) router.Handle("POST", "/user/login/", func(c *gin.Context) { + select { + case <-c.Request.Context().Done(): + return + default: + } + req, err := b.BindLogin(c) if err != nil { r.RenderLogin(c, nil, err) + return } resp, err := s.Login(req) r.RenderLogin(c, resp, err) }) router.Handle("GET", "/index/", func(c *gin.Context) { + select { + case <-c.Request.Context().Done(): + return + default: + } + r.RenderIndex(c, s.Index()) }) diff --git a/internal/mirc/auto/api/v1/web_core.go b/internal/mirc/auto/api/v1/web_core.go index 4f797538..613977fe 100644 --- a/internal/mirc/auto/api/v1/web_core.go +++ b/internal/mirc/auto/api/v1/web_core.go @@ -70,13 +70,26 @@ func RegisterWebCoreServant(e *gin.Engine, s WebCore, b WebCoreBinding, r WebCor // register routes info to router router.Handle("POST", "/user/logout/", func(c *gin.Context) { + select { + case <-c.Request.Context().Done(): + return + default: + } + r.RenderLogout(c, s.Logout()) }) router.Handle("POST", "/user/login/", func(c *gin.Context) { + select { + case <-c.Request.Context().Done(): + return + default: + } + req, err := b.BindLogin(c) if err != nil { r.RenderLogin(c, nil, err) + return } resp, err := s.Login(req) 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) { + select { + case <-c.Request.Context().Done(): + return + default: + } + r.RenderArticles(c, s.Articles()) } 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) { + select { + case <-c.Request.Context().Done(): + return + default: + } + r.RenderIndex(c, s.Index()) }) diff --git a/internal/mirc/auto/api/x/v1/user.go b/internal/mirc/auto/api/x/v1/user.go index 8b579f67..89a3b086 100644 --- a/internal/mirc/auto/api/x/v1/user.go +++ b/internal/mirc/auto/api/x/v1/user.go @@ -66,13 +66,26 @@ func RegisterUserServant(e *gin.Engine, s User, b UserBinding, r UserRender) { // register routes info to router router.Handle("POST", "/user/logout/", func(c *gin.Context) { + select { + case <-c.Request.Context().Done(): + return + default: + } + r.RenderLogout(c, s.Logout()) }) router.Handle("POST", "/user/login/", func(c *gin.Context) { + select { + case <-c.Request.Context().Done(): + return + default: + } + req, err := b.BindLogin(c) if err != nil { r.RenderLogin(c, nil, err) + return } resp, err := s.Login(req) r.RenderLogin(c, resp, err)