gddo-server: redirect HTTP requests to HTTPS

Per the documentation at,
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-by: Dmitri Shuralyov <>
Reviewed-by: Tuo Shan <>
1 file changed