INNER CODE UNIT · Go

handleRenderAllTemplates

machinebox/remoto · console/api/main.go:115

func handleRenderAllTemplates() http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		ctx := appengine.NewContext(r)
		if r.Method != http.MethodPost {
			http.NotFound(w, r)
			return
		}
		def, err := generator.Parse(strings.NewReader(r.FormValue("definition")))
		if err != nil {
			http.Error(w, err.Error(), http.StatusBadRequest)
			return
		}
		w.Header().Set("Content-Type", "application/zip, application/octet-stream")
		w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename=%s.remoto.zip`, def.PackageName))
		ww := zip.NewWriter(w)
		defer ww.Close()
		err = filepath.Walk("templates", func(p string, info os.FileInfo, err error) error {
			if err != nil {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…