HTTPS rewrite is outside scope

This should be handled by a different server than one with a
vanity.Handler installed.

git-svn-id: file:///srv/svn/repo/toyohime/trunk@89 922d331f-388e-da47-97a9-ad700dc0b8b9
This commit is contained in:
jonbetti 2018-06-06 03:48:49 +00:00
parent 3e556645fa
commit 4872118f0b
2 changed files with 5 additions and 9 deletions

View File

@ -8,10 +8,9 @@ BitBucket, etc.). A commonly used vanity import path is
## Features
- Redirects browsers to godoc.org
- Redirects browsers to godoc.org (or somewhere else)
- Redirects Go tool to VCS
- Redirects godoc.org to browsable files
- Redirects HTTP to HTTPS
## Installation

View File

@ -1,3 +1,7 @@
/*
Package vanity implements custom import paths (Go vanity URLs) as an HTTP
handler that can be installed at the vanity URL.
*/
package vanity // import "go.jonnrb.io/vanity"
import (
@ -105,13 +109,6 @@ Nothing to see here; <a href="{{ . }}">move along</a>.
func handlerFrom(tpl *template.Template, redir Redirector) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Redirect to https.
if r.URL.Scheme == "http" {
r.URL.Scheme = "https"
http.Redirect(w, r, r.URL.String(), http.StatusMovedPermanently)
return
}
// Only method supported is GET.
if r.Method != http.MethodGet {
status := http.StatusMethodNotAllowed