|
@@ -32,6 +32,11 @@ func Response(mp *mysqlpool.MySqlPool, sb *basket.Basket, l *logger.Logger, m *m
|
|
|
}
|
|
|
|
|
|
func (this *Engine) Process() bool {
|
|
|
+ // Request was canceled
|
|
|
+ if this.contextDone() {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
this.Wrap.IsBackend = this.Wrap.R.URL.Path == "/cp" || strings.HasPrefix(this.Wrap.R.URL.Path, "/cp/")
|
|
|
this.Wrap.ConfMysqlExists = utils.IsMySqlConfigExists(this.Wrap.DConfig + string(os.PathSeparator) + "mysql.json")
|
|
|
this.Wrap.UrlArgs = append(this.Wrap.UrlArgs, utils.UrlToArray(this.Wrap.R.URL.Path)...)
|
|
@@ -44,6 +49,11 @@ func (this *Engine) Process() bool {
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
+ // Request was canceled
|
|
|
+ if this.contextDone() {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
// Redirect to CP for creating MySQL config file
|
|
|
if !this.Wrap.IsBackend && !this.Wrap.ConfMysqlExists {
|
|
|
this.Wrap.W.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
|
@@ -62,6 +72,11 @@ func (this *Engine) Process() bool {
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
+ // Request was canceled
|
|
|
+ if this.contextDone() {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
// Check for MySQL connection
|
|
|
err := this.Wrap.UseDatabase()
|
|
|
if err != nil {
|
|
@@ -69,6 +84,11 @@ func (this *Engine) Process() bool {
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
+ // Request was canceled
|
|
|
+ if this.contextDone() {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
// Separated logic
|
|
|
if !this.Wrap.IsBackend {
|
|
|
// Maintenance mode
|
|
@@ -95,6 +115,11 @@ func (this *Engine) Process() bool {
|
|
|
return this.Mods.XXXFrontEnd(this.Wrap)
|
|
|
}
|
|
|
|
|
|
+ // Request was canceled
|
|
|
+ if this.contextDone() {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
// Show login page if need
|
|
|
if this.Wrap.S.GetInt("UserId", 0) <= 0 {
|
|
|
// Redirect
|
|
@@ -106,12 +131,22 @@ func (this *Engine) Process() bool {
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
+ // Request was canceled
|
|
|
+ if this.contextDone() {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
// Try load current user data
|
|
|
if !this.Wrap.LoadSessionUser() {
|
|
|
http.Redirect(this.Wrap.W, this.Wrap.R, "/", 302)
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
+ // Request was canceled
|
|
|
+ if this.contextDone() {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
// Only active admins can use backend
|
|
|
if !(this.Wrap.User.A_admin == 1 && this.Wrap.User.A_active == 1) {
|
|
|
// Redirect
|
|
@@ -128,6 +163,11 @@ func (this *Engine) Process() bool {
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
+ // Request was canceled
|
|
|
+ if this.contextDone() {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
// Render backend
|
|
|
return this.Mods.XXXBackEnd(this.Wrap)
|
|
|
}
|
|
@@ -139,3 +179,12 @@ func (this *Engine) redirectFixCpUrl() bool {
|
|
|
}
|
|
|
return false
|
|
|
}
|
|
|
+
|
|
|
+func (this *Engine) contextDone() bool {
|
|
|
+ select {
|
|
|
+ case <-this.Wrap.R.Context().Done():
|
|
|
+ return true
|
|
|
+ default:
|
|
|
+ }
|
|
|
+ return false
|
|
|
+}
|