mirror of https://github.com/knative/docs.git
golang format tools (#1274)
Produced via: `gofmt -s -w $(find -path './vendor' -prune -o -type f -name '*.go' -print))` `goimports -w $(find -name '*.go' | grep -v vendor)`
This commit is contained in:
parent
2985a68440
commit
3037f6970c
|
@ -19,10 +19,10 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Algorithm from https://stackoverflow.com/a/21854246
|
// Algorithm from https://stackoverflow.com/a/21854246
|
||||||
|
@ -156,20 +156,20 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
func replyWithToken(token string) func(http.ResponseWriter, *http.Request) {
|
func replyWithToken(token string) func(http.ResponseWriter, *http.Request) {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Fprintln(w, token)
|
fmt.Fprintln(w, token)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
validateToken := os.Getenv("VALIDATION")
|
validateToken := os.Getenv("VALIDATION")
|
||||||
if validateToken != "" {
|
if validateToken != "" {
|
||||||
http.HandleFunc("/" + validateToken + "/", replyWithToken(validateToken))
|
http.HandleFunc("/"+validateToken+"/", replyWithToken(validateToken))
|
||||||
}
|
}
|
||||||
|
|
||||||
listenPort := os.Getenv("PORT")
|
listenPort := os.Getenv("PORT")
|
||||||
if listenPort == "" {
|
if listenPort == "" {
|
||||||
listenPort = "8080"
|
listenPort = "8080"
|
||||||
}
|
}
|
||||||
http.HandleFunc("/", handler)
|
http.HandleFunc("/", handler)
|
||||||
http.ListenAndServe(":" + listenPort, nil)
|
http.ListenAndServe(":"+listenPort, nil)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue