summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ninjacloud.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/ninjacloud.go b/src/ninjacloud.go
index 9f78cfb..3e1f3e3 100644
--- a/src/ninjacloud.go
+++ b/src/ninjacloud.go
@@ -115,10 +115,10 @@ func writeFile(path string, content []byte, overwrite bool) (err error) {
115 return 115 return
116} 116}
117 117
118/*func readFile(path string) (content []byte, err error) { 118func readFile(path string) (content []byte, err error) {
119 content, err = ioutil.ReadFile(path) 119 content, err = ioutil.ReadFile(path)
120 return 120 return
121}*/ 121}
122 122
123func removeFile(path string) (err error) { 123func removeFile(path string) (err error) {
124 err = os.Remove(path) 124 err = os.Remove(path)
@@ -441,7 +441,21 @@ func fileHandler(w http.ResponseWriter, r *http.Request) {
441 w.Write(j) 441 w.Write(j)
442 return 442 return
443 } else { 443 } else {
444 http.ServeFile(w, r, p) 444 ext := filepath.Ext(p)
445 if ext == ".htm" || ext == ".html" {
446 file, err := readFile(p)
447 if err != nil {
448 log.Println(err)
449 w.WriteHeader(http.StatusInternalServerError)
450 return
451 }
452 w.Header().Set("Content-Type", "text/plain, charset=utf-8")
453 w.WriteHeader(http.StatusOK)
454 w.Write(file)
455 return
456 } else {
457 http.ServeFile(w, r, p)
458 }
445 } 459 }
446 } 460 }
447} 461}