summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ninjacloud.go27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/ninjacloud.go b/src/ninjacloud.go
index 235a9be..5f9274e 100644
--- a/src/ninjacloud.go
+++ b/src/ninjacloud.go
@@ -445,20 +445,23 @@ func fileHandler(w http.ResponseWriter, r *http.Request) {
445 return 445 return
446 } else { 446 } else {
447 ext := filepath.Ext(p) 447 ext := filepath.Ext(p)
448 if ext == ".htm" || ext == ".html" { 448 switch ext {
449 file, err := readFile(p) 449 case ".htm":
450 if err != nil { 450 case ".html":
451 log.Println(err)
452 w.WriteHeader(http.StatusInternalServerError)
453 return
454 }
455 w.Header().Set("Content-Type", "text/plain, charset=utf-8") 451 w.Header().Set("Content-Type", "text/plain, charset=utf-8")
456 w.WriteHeader(http.StatusOK) 452
457 w.Write(file) 453 case ".json":
454 w.Header().Set("Content-Type", "application/json")
455 }
456 file, err := readFile(p)
457 if err != nil {
458 log.Println(err)
459 w.WriteHeader(http.StatusInternalServerError)
458 return 460 return
459 } else {
460 http.ServeFile(w, r, p)
461 } 461 }
462 w.WriteHeader(http.StatusOK)
463 w.Write(file)
464 return
462 } 465 }
463 } 466 }
464} 467}
@@ -664,7 +667,7 @@ func main() {
664 log.Println(err) 667 log.Println(err)
665 return 668 return
666 } 669 }
667 670
668 err = createDir(projectsDir) 671 err = createDir(projectsDir)
669 if err != nil { 672 if err != nil {
670 log.Println(err) 673 log.Println(err)