index redirect now can be overriden by environment variable
This commit is contained in:
7
main.go
7
main.go
@@ -22,6 +22,7 @@ var client = redis.NewClient(&redis.Options{
|
||||
})
|
||||
|
||||
var SECRET string
|
||||
var INDEX_GET_REDIRECT = "http://alv.cx"
|
||||
|
||||
func main() {
|
||||
r := mux.NewRouter()
|
||||
@@ -38,13 +39,17 @@ func main() {
|
||||
SECRET = p
|
||||
}
|
||||
|
||||
if p, ok := os.LookupEnv("INDEX_GET_REDIRECT"); ok {
|
||||
INDEX_GET_REDIRECT = p
|
||||
}
|
||||
|
||||
log.Fatal(http.ListenAndServe(listenAddress, r))
|
||||
}
|
||||
|
||||
func indexHandler(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Println("indexHandler called")
|
||||
if r.Method != "POST" {
|
||||
http.Redirect(w, r, "http://alv.cx", 302)
|
||||
http.Redirect(w, r, INDEX_GET_REDIRECT, 302)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user