Browse Source

http write wraper for actions

Vova Tkach 6 years ago
parent
commit
9a5634d175
3 changed files with 8 additions and 4 deletions
  1. 2 2
      engine/actions/action_mysql.go
  2. 2 2
      engine/actions/action_signin.go
  3. 4 0
      engine/actions/actions.go

+ 2 - 2
engine/actions/action_mysql.go

@@ -6,7 +6,7 @@ import (
 
 func action_mysql(e *Action) {
 	action := e.R.FormValue("action")
-	(*e.W).Write([]byte(fmt.Sprintf(`
+	e.write(fmt.Sprintf(`
 		ModalShowMsg('MySQL Action', 'Hello from web server (%s)');
-	`, action)))
+	`, action))
 }

+ 2 - 2
engine/actions/action_signin.go

@@ -6,7 +6,7 @@ import (
 
 func action_signin(e *Action) {
 	action := e.R.FormValue("action")
-	(*e.W).Write([]byte(fmt.Sprintf(`
+	e.write(fmt.Sprintf(`
 		ModalShowMsg('Login Action', 'Hello from web server (%s)');
-	`, action)))
+	`, action))
 }

+ 4 - 0
engine/actions/actions.go

@@ -19,6 +19,10 @@ func (e *Action) register(name string, handle hRun) {
 	e.list[name] = handle
 }
 
+func (e *Action) write(data string) {
+	(*e.W).Write([]byte(data))
+}
+
 func New(w *http.ResponseWriter, r *http.Request, vhost string, vhosthome string, remoteip string) *Action {
 	act := Action{w, r, vhost, vhosthome, remoteip, make(map[string]hRun)}