httputil: allow full error serving when with devcam

When hacking on e.g. importers, I sometimes want to use devcam with
-hostname, to test with a non local context. In which case, when hitting
an error httputil.ServeError would not print the full error, which
makes it harder to debug.

Change-Id: I2fb8c97748d4f077404fbf12010addd6e7af3572
This commit is contained in:
mpl 2014-04-23 15:19:40 +02:00
parent bfd97aefb3
commit a8f8fd57cf
1 changed files with 2 additions and 1 deletions

View File

@ -27,6 +27,7 @@ import (
"net" "net"
"net/http" "net/http"
"net/url" "net/url"
"os"
"path" "path"
"strconv" "strconv"
"strings" "strings"
@ -63,7 +64,7 @@ func RequestEntityTooLargeError(conn http.ResponseWriter) {
func ServeError(conn http.ResponseWriter, req *http.Request, err error) { func ServeError(conn http.ResponseWriter, req *http.Request, err error) {
conn.WriteHeader(http.StatusInternalServerError) conn.WriteHeader(http.StatusInternalServerError)
if IsLocalhost(req) { if IsLocalhost(req) || os.Getenv("CAMLI_DEV_CAMLI_ROOT") != "" {
fmt.Fprintf(conn, "Server error: %s\n", err) fmt.Fprintf(conn, "Server error: %s\n", err)
return return
} }