2018-12-28から1日間の記事一覧
ResponseWriterにエラーの内容を書き込むことができ、 クライアント側にエラーを認知させることができます。 func pict(w http.ResponseWriter, req *http.Request) { f, err := os.Open("pict.png") if err != nil { http.Error(w, "file not found", 404) …
http.Handle()とhttp.FileServer()を用いた、サーブ方法には問題となる点がありました。 http.FileServer()で階層ごと複数ファイルをサーブする【Go】 - 技術向上 http.Handle("/abc/", http.FileServer(http.Dir("templates"))) 上記の場合、/abc/にアクセ…