oh that was a bad error path.

master
Jordan Orelli 10 years ago
parent 04b8cad832
commit 522acd5064

@ -36,7 +36,6 @@ func main() {
http.Handle("/", &logWrapper{http.FileServer(dir)}) http.Handle("/", &logWrapper{http.FileServer(dir)})
addr := fmt.Sprintf("%s:%d", options.hostname, options.port) addr := fmt.Sprintf("%s:%d", options.hostname, options.port)
log.Printf("init [pid: %d] [machineId: %x] [addr: %s] [cwd: %s]", global.pid, string(global.machineId), addr, cwd)
if err := http.ListenAndServe(addr, nil); err != nil { if err := http.ListenAndServe(addr, nil); err != nil {
bail(1, "unable to start server: %v", err) bail(1, "unable to start server: %v", err)
} }

@ -14,6 +14,11 @@ type logWrapper struct {
} }
func (l *logWrapper) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (l *logWrapper) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/favicon.ico" {
l.Handler.ServeHTTP(w, r)
return
}
id := newRequestId() id := newRequestId()
if IsTerminal(os.Stdout.Fd()) { if IsTerminal(os.Stdout.Fd()) {
log.Println(termcolors.WrapString(termcolors.Magenta, id.String()), r.Method, r.URL) log.Println(termcolors.WrapString(termcolors.Magenta, id.String()), r.Method, r.URL)
@ -52,8 +57,8 @@ func (w *writerWatcher) PrettyStatus() string {
return s return s
} }
switch { switch {
case w.headerWritten < 100: case w.headerWritten == 0:
panic("wtf") return termcolors.WrapString(termcolors.Green, "200")
case w.headerWritten < 200: case w.headerWritten < 200:
return termcolors.WrapString(termcolors.White, s) return termcolors.WrapString(termcolors.White, s)
case w.headerWritten < 300: case w.headerWritten < 300:

Loading…
Cancel
Save