gddo-server: redirect HTTP requests to HTTPS

Per the documentation at
https://cloud.google.com/appengine/docs/flexible/go/how-requests-are-handled,
you can detect whether a request was sent to your App Engine Flex
application with HTTP or HTTPS by checking the X-Forwarded-Proto
header on the request.

This should not interfere with local development since local
development usually does not occur behind a proxy.

I could add tests around either the mux or the apiMux, but those seem
difficult to back out from `func main`.

Fixes golang/gddo#493.

Change-Id: I735d0f8ee650d14a51bf70a3c958429063a48a86
Reviewed-on: https://go-review.googlesource.com/49650
Reviewed-by: Dmitri Shuralyov <shurcool@gmail.com>
Reviewed-by: Tuo Shan <shantuo@google.com>
1 file changed