Commit 643fe8c8 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Document decision to use panic

I am no 100% sure but I think we can only write the HTTP status
code once. So once the 200 is out, we might as well panic on errors.
The Go HTTP server will only let the goroutine crash, not the entire
server process.
parent d7c06697
...@@ -114,7 +114,7 @@ func handle_get_info_refs(user string, _ string, path string, w http.ResponseWri ...@@ -114,7 +114,7 @@ func handle_get_info_refs(user string, _ string, path string, w http.ResponseWri
} }
w.Header().Add("Content-Type", fmt.Sprintf("application/x-%s-advertisement", rpc)) w.Header().Add("Content-Type", fmt.Sprintf("application/x-%s-advertisement", rpc))
no_cache(w) no_cache(w)
w.WriteHeader(200) w.WriteHeader(200) // Don't bother with HTTP 500 from this point on, just panic
if err := pkt_line(w, fmt.Sprintf("# service=%s\n", rpc)); err != nil { if err := pkt_line(w, fmt.Sprintf("# service=%s\n", rpc)); err != nil {
panic(err) panic(err)
} }
...@@ -176,7 +176,7 @@ func handle_post_rpc(user string, rpc string, path string, w http.ResponseWriter ...@@ -176,7 +176,7 @@ func handle_post_rpc(user string, rpc string, path string, w http.ResponseWriter
w.Header().Add("Content-Type", fmt.Sprintf("application/x-%s-result", rpc)) w.Header().Add("Content-Type", fmt.Sprintf("application/x-%s-result", rpc))
no_cache(w) no_cache(w)
w.WriteHeader(200) w.WriteHeader(200) // Don't bother with HTTP 500 from this point on, just panic
if _, err := io.Copy(w, stdout); err != nil { if _, err := io.Copy(w, stdout); err != nil {
panic(err) // No point in sending 500 to the client panic(err) // No point in sending 500 to the client
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment