zardoz/main.go

54 lines
1.1 KiB
Go
Raw Normal View History

2020-10-08 15:53:05 -04:00
package main
import (
"log"
"net/http"
"net/http/httputil"
"net/url"
"os"
"strconv"
)
func main() {
vip := os.Getenv("REVERSEURL")
pport := os.Getenv("PROXYPORT")
sensitivity := os.Getenv("TRIGGER")
maturity := os.Getenv("SENIORITY")
collect := os.Getenv("COLLECTION")
log.Println("Reverse path is: ", vip)
log.Println("Reverse port is: ", pport)
remote, err := url.Parse(vip)
if err != nil {
panic(err)
}
ProxyFlow.sensitivity, err = strconv.ParseFloat(sensitivity, 64)
if err != nil {
ProxyFlow.sensitivity = 0.5
}
log.Println("Trigger is: ", ProxyFlow.sensitivity)
Maturity, err = strconv.ParseInt(maturity, 10, 64)
if err != nil {
Maturity = 1024
}
log.Println("Minimum request to learn: ", Maturity)
ProxyFlow.collection, err = strconv.ParseFloat(collect, 64)
if err != nil {
// This is because we assume every example should add at least one token
ProxyFlow.collection = float64(Maturity)
}
log.Println("Collection limit is: ", ProxyFlow.collection)
proxy := httputil.NewSingleHostReverseProxy(remote)
http.HandleFunc("/", handler(proxy))
err = http.ListenAndServe(pport, nil)
if err != nil {
panic(err)
}
}