-
Hugo NOUTS authoredHugo NOUTS authored
main.go 816 B
package main
import (
"flag"
"fmt"
"net/http"
"strconv"
"strings"
)
var (
httpPort = flag.Int("http_port", 80, "HTTP port to serve on (defaults to 80)")
)
func main() {
// Parse the flags
flag.Parse()
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query()
fmt.Println(query)
host := strings.Split(query.Get("state"), "-")[1]
fmt.Println(host)
state := query.Get("state")
fmt.Println(state)
usagePointId := query.Get("usage_point_id")
fmt.Println(usagePointId)
code := query.Get("code")
fmt.Println(code)
redir := "https://" + host + "?code=" + code + "&state="+ state +"&usage_point_id=" + usagePointId
fmt.Println(redir)
http.Redirect(w, r, redir, 302)
})
http.ListenAndServe(":"+strconv.Itoa(*httpPort), mux)
}