-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.go
90 lines (76 loc) · 1.75 KB
/
plugin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package mware
/*
import (
"net/http"
"reflect"
"github.com/zaolab/sunnified/mvc"
"github.com/zaolab/sunnified/mvc/controller"
"github.com/zaolab/sunnified/web"
"sync"
)
type PluginMiddleWare struct {
BaseMiddleWare
reqvalue reflect.Value
}
func (this *PluginMiddleWare) Request(ctxt *web.Context) {
this.BaseMiddleWare.Context = ctxt
wait := sync.WaitGroup{}
plugins := make([]reflect.Value, 0)
this.reqvalue = reflect.ValueOf(*ctxt.Request)
args := []reflect.Value{this.reqvalue}
for _, plugin := range plugins {
wait.Add(1)
go func() {
defer wait.Done()
plugin.Call(args)
}()
}
wait.Wait()
}
func (this *PluginMiddleWare) Controller(con *controller.ControlManager) {
wait := sync.WaitGroup{}
plugins := make([]reflect.Value, 0)
args := []reflect.Value{this.reqvalue, reflect.ValueOf(con)}
for _, plugin := range plugins {
wait.Add(1)
go func() {
defer wait.Done()
plugin.Call(args)
}()
}
wait.Wait()
}
func (this *PluginMiddleWare) View(view mvc.View) {
wait := sync.WaitGroup{}
plugins := make([]reflect.Value, 0)
args := []reflect.Value{this.reqvalue, reflect.ValueOf(view)}
for _, plugin := range plugins {
wait.Add(1)
go func() {
defer wait.Done()
plugin.Call(args)
}()
}
wait.Wait()
}
func (this *PluginMiddleWare) Response() {
wait := sync.WaitGroup{}
plugins := make([]reflect.Value, 0)
header := this.BaseMiddleWare.Context.Response.Header()
copyheader := make(map[string][]string)
for k, v := range header {
val := make([]string, len(v))
copy(val, v)
copyheader[k] = val
}
args := []reflect.Value{this.reqvalue, reflect.ValueOf(http.Header(copyheader))}
for _, plugin := range plugins {
wait.Add(1)
go func() {
defer wait.Done()
plugin.Call(args)
}()
}
wait.Wait()
}
*/