@@ -21,16 +21,16 @@ import (
2121//ng:generate def obj Midware
2222type Midware struct {
2323 sni utils.GroupRegexp
24- bufferedLookupForSNI * utils.BufferedLookup
24+ bufferedLookupForSNI * utils.BufferedLookup [ bool ]
2525
2626 current []* ServiceStruct
27- bufferedLookupForHost * utils.BufferedLookup
27+ bufferedLookupForHost * utils.BufferedLookup [[] * ServiceStruct ]
2828
2929 currentCgi []* CgiStruct
30- bufferedLookupForCgi * utils.BufferedLookup
30+ bufferedLookupForCgi * utils.BufferedLookup [[] * CgiStruct ]
3131
3232 currentForward []* ServiceStruct
33- bufferedLookupForForward * utils.BufferedLookup
33+ bufferedLookupForForward * utils.BufferedLookup [[] * ServiceStruct ]
3434
3535 muActiveRequest sync.RWMutex
3636 activeRequests map [string ]* HttpCtx
@@ -85,7 +85,7 @@ var h2s = &http2.Server{}
8585func (h * Midware ) Handle (c * tcp.Conn ) tcp.SerRet {
8686 top := c .TopProtocol ()
8787 sni , ok := c .Load (tcp .KeyTlsSni )
88- if ok && ! h .bufferedLookupForSNI .Lookup (sni .(string )).( bool ) {
88+ if ok && ! h .bufferedLookupForSNI .Lookup (sni .(string )) {
8989 return tcp .Continue
9090 }
9191 switch top {
@@ -189,7 +189,7 @@ func (h *Midware) Process(RequestCtx *HttpCtx) {
189189 }
190190
191191 {
192- ServicesToExecute := h .bufferedLookupForHost .Lookup (RequestCtx .Req .Host ).([] * ServiceStruct )
192+ ServicesToExecute := h .bufferedLookupForHost .Lookup (RequestCtx .Req .Host )
193193 for i := 0 ; i < len (ServicesToExecute ); i ++ {
194194
195195 RequestPath += ServicesToExecute [i ].Id + " " // record the executed service
@@ -228,7 +228,7 @@ func NewHttpMidware(sni []string) *Midware {
228228 },
229229 }
230230
231- hmw .bufferedLookupForHost = utils .NewBufferedLookup (func (s string ) interface {} {
231+ hmw .bufferedLookupForHost = utils .NewBufferedLookup (func (s string ) [] * ServiceStruct {
232232 ret := make ([]* ServiceStruct , 0 )
233233 for _ , r := range hmw .current {
234234 if r .Hosts .MatchString (s ) {
@@ -238,7 +238,7 @@ func NewHttpMidware(sni []string) *Midware {
238238 return ret
239239 })
240240
241- hmw .bufferedLookupForCgi = utils .NewBufferedLookup (func (s string ) interface {} {
241+ hmw .bufferedLookupForCgi = utils .NewBufferedLookup (func (s string ) [] * CgiStruct {
242242 var m []* CgiStruct = nil
243243 for _ , t := range hmw .currentCgi {
244244 for _ , r := range t .CgiPaths {
@@ -250,7 +250,7 @@ func NewHttpMidware(sni []string) *Midware {
250250 return m
251251 })
252252
253- hmw .bufferedLookupForForward = utils .NewBufferedLookup (func (s string ) interface {} {
253+ hmw .bufferedLookupForForward = utils .NewBufferedLookup (func (s string ) [] * ServiceStruct {
254254 ret := make ([]* ServiceStruct , 0 )
255255 for _ , r := range hmw .currentForward {
256256 if r .Hosts .MatchString (s ) {
@@ -260,7 +260,7 @@ func NewHttpMidware(sni []string) *Midware {
260260 return ret
261261 })
262262
263- hmw .bufferedLookupForSNI = utils .NewBufferedLookup (func (s string ) interface {} {
263+ hmw .bufferedLookupForSNI = utils .NewBufferedLookup (func (s string ) bool {
264264 return hmw .sni == nil || hmw .sni .MatchString (s )
265265 })
266266
0 commit comments