summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 950446b)
raw | patch | inline | side by side (parent: 950446b)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 23 Nov 2014 15:02:07 +0000 (16:02 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 23 Nov 2014 15:02:07 +0000 (16:02 +0100) |
server/error.go | patch | blob | history | |
server/graph.go | patch | blob | history | |
server/server.go | patch | blob | history |
diff --git a/server/error.go b/server/error.go
index 49fec434712585a015cbf0058500dee05649cf35..2afa44ab98e570c5d43c9aa08508599e0a986bea 100644 (file)
--- a/server/error.go
+++ b/server/error.go
s.err(w, http.StatusNotFound, fmt.Errorf("%s not found", r.RequestURI))
}
+func (s *Server) badrequest(w http.ResponseWriter, err error) {
+ s.err(w, http.StatusBadRequest, err)
+}
+
func (s *Server) internal(w http.ResponseWriter, err error) {
s.err(w, http.StatusInternalServerError, err)
}
diff --git a/server/graph.go b/server/graph.go
index 9406f760158029519ecf32edb07f7993c6dfc632..941e51de6b8a994b65111c26181178e7cc2258c4 100644 (file)
--- a/server/graph.go
+++ b/server/graph.go
func (s *Server) graph(w http.ResponseWriter, req request) {
if len(req.args) != 2 {
- s.internal(w, fmt.Errorf("Missing host/metric information"))
+ s.badrequest(w, fmt.Errorf("Missing host/metric information"))
}
host := proto.EscapeString(req.args[0])
diff --git a/server/server.go b/server/server.go
index 309cdb6b35f86541dc528b6f6df742cf30d51f39..6b3f8d07a57e5ae715fb828df75cb1f4c556332c 100644 (file)
--- a/server/server.go
+++ b/server/server.go
for _, f := range strings.Split(path, "/") {
f, err := url.QueryUnescape(f)
if err != nil {
- s.err(w, http.StatusBadRequest, fmt.Errorf("Error: %v", err))
+ s.badrequest(w, fmt.Errorf("Error: %v", err))
return
}
fields = append(fields, f)
r.ParseForm()
page, err := f(req, s)
if err != nil {
- s.err(w, http.StatusBadRequest, fmt.Errorf("Error: %v", err))
+ s.badrequest(w, fmt.Errorf("Error: %v", err))
return
}