Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
|
2912909957 | |
|
ed411d5a5c |
|
@ -8,7 +8,7 @@ import (
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Develop = true
|
var Develop = false
|
||||||
|
|
||||||
type RegisterResponse struct {
|
type RegisterResponse struct {
|
||||||
ID string
|
ID string
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package web
|
package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"mime"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
@ -19,7 +17,7 @@ func (web *Web) indexHandler(entryPoint string) func(w http.ResponseWriter, r *h
|
||||||
log.Error().Err(err).Msg("Error finding file")
|
log.Error().Err(err).Msg("Error finding file")
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
}
|
}
|
||||||
write(w, f, p)
|
w.Write(f)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if web.box.HasDir(p) && web.box.Has(path.Join(p, "index.html")) {
|
if web.box.HasDir(p) && web.box.Has(path.Join(p, "index.html")) {
|
||||||
|
@ -28,12 +26,12 @@ func (web *Web) indexHandler(entryPoint string) func(w http.ResponseWriter, r *h
|
||||||
log.Error().Err(err).Msg("Error finding file")
|
log.Error().Err(err).Msg("Error finding file")
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
}
|
}
|
||||||
write(w, f, p)
|
w.Write(f)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if f, err := web.box.Find(p); err != nil {
|
if f, err := web.box.Find(p); err != nil {
|
||||||
write(w, f, p)
|
w.Write(f)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,16 +39,3 @@ func (web *Web) indexHandler(entryPoint string) func(w http.ResponseWriter, r *h
|
||||||
}
|
}
|
||||||
return fn
|
return fn
|
||||||
}
|
}
|
||||||
|
|
||||||
func write(w http.ResponseWriter, f []byte, path string) {
|
|
||||||
ctype := mime.TypeByExtension(filepath.Ext(path))
|
|
||||||
log.Debug().Msgf("detected type %s for %s by extension", ctype, path)
|
|
||||||
if ctype == "" {
|
|
||||||
ctype = http.DetectContentType(f)
|
|
||||||
log.Debug().Msgf("detected type %s for %s by content", ctype, path)
|
|
||||||
}
|
|
||||||
if ctype != "" {
|
|
||||||
w.Header().Set("Content-Type", ctype)
|
|
||||||
}
|
|
||||||
w.Write(f)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue