app: use app.yaml directive to redirect to HTTPS

Change-Id: I8d24a60b37fb70ad57b76401dc5d7ce2afb4858f
Reviewed-on: https://go-review.googlesource.com/22448
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/app/app.yaml b/app/app.yaml
index e4c0d2b..624ec4b 100644
--- a/app/app.yaml
+++ b/app/app.yaml
@@ -7,9 +7,13 @@
 - url: /favicon.ico
   static_files: static/favicon.ico
   upload: static/favicon.ico
+  secure: always
 - url: /static
   static_dir: static
+  secure: always
 - url: /(|compile|fmt|share|playground.js)
   script: _go_app
+  secure: always
 - url: /p/.+
   script: _go_app
+  secure: always
diff --git a/app/goplay/compile.go b/app/goplay/compile.go
index 0619587..be1e3e7 100644
--- a/app/goplay/compile.go
+++ b/app/goplay/compile.go
@@ -16,7 +16,7 @@
 const runUrl = "http://golang.org/compile?output=json"
 
 func init() {
-	http.HandleFunc("/compile", httpsOnlyHandler{compile})
+	http.HandleFunc("/compile", compile)
 }
 
 func compile(w http.ResponseWriter, r *http.Request) {
diff --git a/app/goplay/edit.go b/app/goplay/edit.go
index 8d9600a..ce29a78 100644
--- a/app/goplay/edit.go
+++ b/app/goplay/edit.go
@@ -16,7 +16,7 @@
 const hostname = "play.golang.org"
 
 func init() {
-	http.HandleFunc("/", httpsOnlyHandler{edit})
+	http.HandleFunc("/", edit)
 }
 
 var editTemplate = template.Must(template.ParseFiles("goplay/edit.html"))
diff --git a/app/goplay/fmt.go b/app/goplay/fmt.go
index 4cda931..a862343 100644
--- a/app/goplay/fmt.go
+++ b/app/goplay/fmt.go
@@ -13,7 +13,7 @@
 )
 
 func init() {
-	http.HandleFunc("/fmt", httpsOnlyHandler{fmtHandler})
+	http.HandleFunc("/fmt", fmtHandler)
 }
 
 type fmtResponse struct {
diff --git a/app/goplay/https.go b/app/goplay/https.go
deleted file mode 100644
index 93297ac..0000000
--- a/app/goplay/https.go
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2016 The Go Authors.  All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package goplay
-
-import (
-	"net/http"
-
-	"appengine"
-)
-
-// httpsOnlyHandler redirects requests to "http://example.com/foo?bar"
-// to "https://example.com/foo?bar"
-type httpsOnlyHandler struct {
-	fn http.HandlerFunc
-}
-
-func (h httpsOnlyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
-	if !appengine.IsDevAppServer() && r.TLS == nil {
-		r.URL.Scheme = "https"
-		r.URL.Host = r.Host
-		http.Redirect(w, r, r.URL.String(), http.StatusFound)
-		return
-	}
-	h.fn(w, r)
-}
diff --git a/app/goplay/play.go b/app/goplay/play.go
index 0dcee31..b8257f1 100644
--- a/app/goplay/play.go
+++ b/app/goplay/play.go
@@ -12,7 +12,7 @@
 )
 
 func init() {
-	http.HandleFunc("/playground.js", httpsOnlyHandler{play})
+	http.HandleFunc("/playground.js", play)
 }
 
 func play(w http.ResponseWriter, r *http.Request) {
diff --git a/app/goplay/share.go b/app/goplay/share.go
index e0c16a0..72fca10 100644
--- a/app/goplay/share.go
+++ b/app/goplay/share.go
@@ -35,7 +35,7 @@
 }
 
 func init() {
-	http.HandleFunc("/share", httpsOnlyHandler{share})
+	http.HandleFunc("/share", share)
 }
 
 func share(w http.ResponseWriter, r *http.Request) {