Browse Source

Add sessions to actions

Vova Tkach 6 years ago
parent
commit
2612dc773c
2 changed files with 6 additions and 3 deletions
  1. 5 2
      engine/actions/actions.go
  2. 1 1
      engine/wrapper/wrapper.go

+ 5 - 2
engine/actions/actions.go

@@ -4,6 +4,8 @@ import (
 	"fmt"
 	"net/http"
 	"strings"
+
+	"golang-fave/engine/sessions"
 )
 
 type hRun func(e *Action)
@@ -14,6 +16,7 @@ type Action struct {
 	VHost     string
 	VHostHome string
 	RemoteIp  string
+	Session   *sessions.Session
 	list      map[string]hRun
 }
 
@@ -40,8 +43,8 @@ func (e *Action) msg_error(msg string) {
 	e.msg_show("Error", msg)
 }
 
-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)}
+func New(w *http.ResponseWriter, r *http.Request, vhost string, vhosthome string, remoteip string, session *sessions.Session) *Action {
+	act := Action{w, r, vhost, vhosthome, remoteip, session, make(map[string]hRun)}
 
 	// Register all action here
 	act.register("mysql", action_mysql)

+ 1 - 1
engine/wrapper/wrapper.go

@@ -146,7 +146,7 @@ func (e *Wrapper) Run(hRun handleRun) {
 	}
 
 	// Create action
-	e.Action = actions.New(e.W, e.R, e.VHost, e.DirVhostHome, e.RemoteIp)
+	e.Action = actions.New(e.W, e.R, e.VHost, e.DirVhostHome, e.RemoteIp, e.Session)
 
 	// Call action
 	if e.Action.Call() {