0
動的HTMLテンプレートで応答するルートを設定しました。Golangは、データが読み込まれるのを待つ間に静的なHTMLテンプレートを表示します。
package main
import (
"net/http"
"html/template"
)
func index(w http.ResponseWriter, r *http.Request) {
showWwResult, _ := GetWw()
showHoursResult, _ := GetHours()
type Data struct {
ShowWwResult []IssueResult
ShowHoursResult Page
}
data := Data{showWwResult, showHoursResult}
var templates = template.Must(template.ParseFiles("templates/index.html", "templates/ww.html", "templates/hours.html"))
templates.ExecuteTemplate(w, "indexPage", data)
}
私の問題は、それがHTMLをレンダリングする前に戻すには、このためのデータとページ待機を収集するために非常に長い時間を要し、です。
私は私が完了するGetWw()
とGetHours()
を待っている間、それは、何か、何かを返すように取得できますか? HTMLテンプレートの静的部分を表示して、準備が整ったらページをShowWwResult
とShowHoursResult
に設定する方法はありますか?
「待ってください」というメッセージが表示されたリダイレクトページを送信することが最善の策だと思いますが、私はHTTPの専門家ではありません... –