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
| package handler
import (
"net/http"
"os"
"strings"
_ "unsafe"
_ "github.com/hoppscotch/proxyscotch/libproxy"
)
//go:linkname proxyHandler github.com/hoppscotch/proxyscotch/libproxy.proxyHandler
func proxyHandler(w http.ResponseWriter, r *http.Request)
//go:linkname accessToken github.com/hoppscotch/proxyscotch/libproxy.accessToken
var accessToken string
//go:linkname allowedOrigins github.com/hoppscotch/proxyscotch/libproxy.allowedOrigins
var allowedOrigins []string
//go:linkname bannedOutputs github.com/hoppscotch/proxyscotch/libproxy.bannedOutputs
var bannedOutputs []string
//go:linkname bannedDests github.com/hoppscotch/proxyscotch/libproxy.bannedDests
var bannedDests []string
func Handler(w http.ResponseWriter, r *http.Request) {
if os.Getenv("ACCESS_TOKEN") != "" {
accessToken = os.Getenv("ACCESS_TOKEN")
}
if os.Getenv("ALLOWED_ORIGINS") != "" {
allowedOrigins = strings.Split(os.Getenv("ALLOWED_ORIGINS"), ",")
} else {
allowedOrigins = []string{"*"}
}
if os.Getenv("BANNED_OUTPUTS") != "" {
bannedOutputs = strings.Split(os.Getenv("BANNED_OUTPUTS"), ",")
}
if os.Getenv("BANNED_DESTINATIONS") != "" {
bannedDests = strings.Split(os.Getenv("BANNED_DESTINATIONS"), ",")
}
proxyHandler(w, r)
}
|