Slightly simplified
This commit is contained in:
@@ -35,13 +35,13 @@ func webserver(mongoStr string) {
|
|||||||
client, err := mongo.NewClient(options.Client().ApplyURI(mongoStr))
|
client, err := mongo.NewClient(options.Client().ApplyURI(mongoStr))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Issues connecting to mongo:", err)
|
log.Println("Issues connecting to mongo:", err)
|
||||||
quitChan <- "web arg"
|
quitChan <- "web err"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = client.Connect(context.TODO())
|
err = client.Connect(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Issues connecting to mongo:", err)
|
log.Println("Issues connecting to mongo:", err)
|
||||||
quitChan <- "web arg"
|
quitChan <- "web err"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
stupid := stupid.NewStupidBackend(db.NewMongoTable(client.Database("stupid").Collection("keys")))
|
stupid := stupid.NewStupidBackend(db.NewMongoTable(client.Database("stupid").Collection("keys")))
|
||||||
@@ -84,28 +84,22 @@ func webserver(mongoStr string) {
|
|||||||
})
|
})
|
||||||
http.Handle("api.darkstorm.tech/", stupid)
|
http.Handle("api.darkstorm.tech/", stupid)
|
||||||
}
|
}
|
||||||
|
url, err := url.Parse("https://localhost:30000")
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Can't parse foundry url:", err)
|
||||||
|
quitChan <- "web err"
|
||||||
|
return
|
||||||
|
}
|
||||||
http.Handle("/", http.FileServer(http.Dir(path)))
|
http.Handle("/", http.FileServer(http.Dir(path)))
|
||||||
http.Handle("/SWAssistant/", swaHandler{})
|
http.Handle("/SWAssistant/", swaHandler{})
|
||||||
http.Handle("/CDR/", cdrHandler{})
|
http.Handle("/CDR/", cdrHandler{})
|
||||||
http.Handle("rpg.darkstorm.tech/", sup{})
|
http.Handle("rpg.darkstorm.tech/", httputil.NewSingleHostReverseProxy(url))
|
||||||
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||||
err := http.ListenAndServeTLS(":443", keyPath+"/fullchain.pem", keyPath+"/key.pem", nil)
|
err = http.ListenAndServeTLS(":443", keyPath+"/fullchain.pem", keyPath+"/key.pem", nil)
|
||||||
log.Println("Error while serving website:", err)
|
log.Println("Error while serving website:", err)
|
||||||
quitChan <- "web err"
|
quitChan <- "web err"
|
||||||
}
|
}
|
||||||
|
|
||||||
type sup struct{}
|
|
||||||
|
|
||||||
func (s sup) ServeHTTP(writer http.ResponseWriter, req *http.Request) {
|
|
||||||
url, err := url.Parse("https://localhost:30000")
|
|
||||||
if err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
http.FileServer(http.Dir(flag.Arg(0))).ServeHTTP(writer, req)
|
|
||||||
}
|
|
||||||
rvProx := httputil.NewSingleHostReverseProxy(url)
|
|
||||||
rvProx.ServeHTTP(writer, req)
|
|
||||||
}
|
|
||||||
|
|
||||||
type swaHandler struct{}
|
type swaHandler struct{}
|
||||||
|
|
||||||
func (swaHandler) ServeHTTP(writer http.ResponseWriter, req *http.Request) {
|
func (swaHandler) ServeHTTP(writer http.ResponseWriter, req *http.Request) {
|
||||||
|
|||||||
Reference in New Issue
Block a user