-
Notifications
You must be signed in to change notification settings - Fork 141
/
headerFilter.go
65 lines (53 loc) · 1.5 KB
/
headerFilter.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
// you can define your handle to processing your private header before or after process message
package lhttp
import (
"container/list"
// "log"
)
var (
onOpenFilterList *list.List
beforeRequestFilterList *list.List
afterRequestFilterList *list.List
onCloseFilterList *list.List
)
type HeadFilterHandler interface {
OnOpenFilterHandle(*WsHandler)
BeforeRequestFilterHandle(*WsHandler)
AfterRequestFilterHandle(*WsHandler)
OnCloseFilterHandle(*WsHandler)
}
//define your filter need combine base
/*
type YourFilter struct {
*HeadFilterBase
}
*/
type HeadFilterBase struct{}
func (*HeadFilterBase) BeforeRequestFilterHandle(ws *WsHandler) {
// log.Print("head base filter before request")
}
func (*HeadFilterBase) AfterRequestFilterHandle(ws *WsHandler) {
// log.Print("head base filter after request")
}
func (*HeadFilterBase) OnOpenFilterHandle(ws *WsHandler) {
// log.Print("head base filter on open")
}
func (*HeadFilterBase) OnCloseFilterHandle(ws *WsHandler) {
// log.Print("head base filter on close")
}
func RegistHeadFilter(h HeadFilterHandler) {
onOpenFilterList.PushBack(h)
beforeRequestFilterList.PushBack(h)
afterRequestFilterList.PushBack(h)
onCloseFilterList.PushBack(h)
}
func init() {
onOpenFilterList = list.New()
beforeRequestFilterList = list.New()
afterRequestFilterList = list.New()
onCloseFilterList = list.New()
// RegistHeadFilter(&HeadFilterBase{})
RegistHeadFilter(&mqHeadFilter{})
RegistHeadFilter(&upstreamHeadFilter{})
RegistHeadFilter(&multipartFilter{})
}