0
私はこれにはまったく関係ないかもしれませんが、私の基本的なローカルホストサーバーにはHTTP2がありません。なぜなら、私は通常キャディの後ろにプロキシをします。このサイドプロジェクトでは、Goで基本的なサーバーを作成して実行しましたが、問題なく動作しますが、ヘッダーには2.0ではなくHTTP/1.1が表示されます。何が問題なのですか?HTTP2はローカルホストでデフォルトで有効になっていません
package main
import (
"fmt"
"net/http"
"html/template"
"os"
)
func IfError(err error, Quit bool) {
if err != nil {
fmt.Println(err.Error())
if(Quit) {
os.Exit(1);
}
}
}
func ServeHome(w http.ResponseWriter, r *http.Request) {
t, err := template.ParseFiles("html/home")
IfError(err, false)
err = t.Execute(w, nil)
IfError(err, false)
}
func RedirectRoot(fs http.Handler, home http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/" {
home.ServeHTTP(w, r)
} else {
fs.ServeHTTP(w, r)
}
})
}
func main() {
proto := ":8081"
ServeFiles := http.FileServer(http.Dir("static/"))
http.Handle("/", RedirectRoot(ServeFiles, http.HandlerFunc(ServeHome)))
fmt.Printf("Listening on ... %s", proto)
IfError(http.ListenAndServe(proto, nil), true)
}
非常に基本的なものですが、ドキュメンテーションはデフォルトで動作するとは言えません。また、私のgoバージョンは1.8.3