Skip to content

Instantly share code, notes, and snippets.

@michaljemala
Last active August 29, 2015 14:17
Show Gist options
  • Save michaljemala/a5cdfd0f3ca47b76f092 to your computer and use it in GitHub Desktop.
Save michaljemala/a5cdfd0f3ca47b76f092 to your computer and use it in GitHub Desktop.
A sample Go app demonstrating the 150.214.47.153:35443 is not accessible on PWS
package main
import (
"fmt"
"log"
"net"
"net/http"
"os"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
conn, err := net.Dial("tcp", "150.214.47.153:35443")
if err != nil {
http.Error(w, err.Error(), 500)
return
}
defer conn.Close()
fmt.Fprintf(w, "OK")
})
var port string
if port = os.Getenv("PORT"); port == "" {
port = "8080"
}
log.Printf("Listening at port %v\n", port)
if err := http.ListenAndServe(":"+port, nil); err != nil {
log.Fatal(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment