//Handler returns handler that will serve a given gopherjs app func (app App) Handler() http.HandlerFunc { return func(response http.ResponseWriter, request *http.Request) { //TODO this is clearly for dev only if request.URL.Path != "/" { log.Println(request.URL.Path) goPath := os.Getenv("GOPATH") http.ServeFile(response, request, goPath+"/src"+request.URL.Path) return } //TODO dont do this here err := app.compile(response) if err != nil { //http.Error(response, err.Error(), http.StatusInternalServerError) return } page := html.Html().Children( html.Head().Children( html.Script().Src(app.CompiledJsFileWebPath()), ), html.Body(), ) page.WriteTo(response) } }
//This is the default blank html page. that contains required clientside js code to have nadeshiko working func Page(path string) io.WriterTo { return html.Html().Children( html.Head().Children( Scripts(path)..., ), html.Body(), ) }
//Handler returns handler that will serve a given gopherjs app func (app App) Handler() http.HandlerFunc { return func(response http.ResponseWriter, request *http.Request) { //TODO dont do this here err := app.compile() if err != nil { http.Error(response, err.Error(), http.StatusInternalServerError) return } page := html.Html().Children( html.Head().Children( html.Script().Src(app.CompiledJsFileWebPath()), ), html.Body(), ) page.WriteTo(response) } }