forked from aau-network-security/haaukins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
svcs.go
33 lines (25 loc) · 703 Bytes
/
svcs.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
// Copyright (c) 2018-2019 Aalborg University
// Use of this source code is governed by a GPLv3
// license that can be found in the LICENSE file.
package svcs
import (
"net/http"
"github.com/tpanum/haaukins/store"
)
type ProxyConnector func(store.EventFile) http.Handler
type Interception interface {
ValidRequest(r *http.Request) bool
Intercept(http.Handler) http.Handler
}
type Interceptors []Interception
func (inter Interceptors) Intercept(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
for _, i := range inter {
if i.ValidRequest(r) {
i.Intercept(next).ServeHTTP(w, r)
return
}
}
next.ServeHTTP(w, r)
})
}