|
|
@@ -336,7 +336,7 @@ func (s *Server) HandleGet(w http.ResponseWriter, r *Request) {
|
|
|
key, err := s.api.Resolve(r.uri)
|
|
|
if err != nil {
|
|
|
getFail.Inc(1)
|
|
|
- s.Error(w, r, fmt.Errorf("error resolving %s: %s", r.uri.Addr, err))
|
|
|
+ s.NotFound(w, r, fmt.Errorf("error resolving %s: %s", r.uri.Addr, err))
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -421,7 +421,7 @@ func (s *Server) HandleGetFiles(w http.ResponseWriter, r *Request) {
|
|
|
key, err := s.api.Resolve(r.uri)
|
|
|
if err != nil {
|
|
|
getFilesFail.Inc(1)
|
|
|
- s.Error(w, r, fmt.Errorf("error resolving %s: %s", r.uri.Addr, err))
|
|
|
+ s.NotFound(w, r, fmt.Errorf("error resolving %s: %s", r.uri.Addr, err))
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -494,7 +494,7 @@ func (s *Server) HandleGetList(w http.ResponseWriter, r *Request) {
|
|
|
key, err := s.api.Resolve(r.uri)
|
|
|
if err != nil {
|
|
|
getListFail.Inc(1)
|
|
|
- s.Error(w, r, fmt.Errorf("error resolving %s: %s", r.uri.Addr, err))
|
|
|
+ s.NotFound(w, r, fmt.Errorf("error resolving %s: %s", r.uri.Addr, err))
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -598,7 +598,7 @@ func (s *Server) HandleGetFile(w http.ResponseWriter, r *Request) {
|
|
|
key, err := s.api.Resolve(r.uri)
|
|
|
if err != nil {
|
|
|
getFileFail.Inc(1)
|
|
|
- s.Error(w, r, fmt.Errorf("error resolving %s: %s", r.uri.Addr, err))
|
|
|
+ s.NotFound(w, r, fmt.Errorf("error resolving %s: %s", r.uri.Addr, err))
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -628,7 +628,7 @@ func (s *Server) HandleGetFile(w http.ResponseWriter, r *Request) {
|
|
|
|
|
|
s.logDebug(fmt.Sprintf("Multiple choices! --> %v", list))
|
|
|
//show a nice page links to available entries
|
|
|
- ShowMultipleChoices(w, &r.Request, list)
|
|
|
+ ShowMultipleChoices(w, r, list)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -693,7 +693,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
|
// strictly a traditional PUT request which replaces content
|
|
|
// at a URI, and POST is more ubiquitous)
|
|
|
if uri.Raw() || uri.DeprecatedRaw() {
|
|
|
- ShowError(w, r, fmt.Sprintf("No PUT to %s allowed.", uri), http.StatusBadRequest)
|
|
|
+ ShowError(w, req, fmt.Sprintf("No PUT to %s allowed.", uri), http.StatusBadRequest)
|
|
|
return
|
|
|
} else {
|
|
|
s.HandlePostFiles(w, req)
|
|
|
@@ -701,7 +701,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
case "DELETE":
|
|
|
if uri.Raw() || uri.DeprecatedRaw() {
|
|
|
- ShowError(w, r, fmt.Sprintf("No DELETE to %s allowed.", uri), http.StatusBadRequest)
|
|
|
+ ShowError(w, req, fmt.Sprintf("No DELETE to %s allowed.", uri), http.StatusBadRequest)
|
|
|
return
|
|
|
}
|
|
|
s.HandleDelete(w, req)
|
|
|
@@ -725,7 +725,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
|
s.HandleGetFile(w, req)
|
|
|
|
|
|
default:
|
|
|
- ShowError(w, r, fmt.Sprintf("Method "+r.Method+" is not supported.", uri), http.StatusMethodNotAllowed)
|
|
|
+ ShowError(w, req, fmt.Sprintf("Method "+r.Method+" is not supported.", uri), http.StatusMethodNotAllowed)
|
|
|
|
|
|
}
|
|
|
}
|
|
|
@@ -757,13 +757,13 @@ func (s *Server) logError(format string, v ...interface{}) {
|
|
|
}
|
|
|
|
|
|
func (s *Server) BadRequest(w http.ResponseWriter, r *Request, reason string) {
|
|
|
- ShowError(w, &r.Request, fmt.Sprintf("Bad request %s %s: %s", r.Method, r.uri, reason), http.StatusBadRequest)
|
|
|
+ ShowError(w, r, fmt.Sprintf("Bad request %s %s: %s", r.Request.Method, r.uri, reason), http.StatusBadRequest)
|
|
|
}
|
|
|
|
|
|
func (s *Server) Error(w http.ResponseWriter, r *Request, err error) {
|
|
|
- ShowError(w, &r.Request, fmt.Sprintf("Error serving %s %s: %s", r.Method, r.uri, err), http.StatusInternalServerError)
|
|
|
+ ShowError(w, r, fmt.Sprintf("Error serving %s %s: %s", r.Request.Method, r.uri, err), http.StatusInternalServerError)
|
|
|
}
|
|
|
|
|
|
func (s *Server) NotFound(w http.ResponseWriter, r *Request, err error) {
|
|
|
- ShowError(w, &r.Request, fmt.Sprintf("NOT FOUND error serving %s %s: %s", r.Method, r.uri, err), http.StatusNotFound)
|
|
|
+ ShowError(w, r, fmt.Sprintf("NOT FOUND error serving %s %s: %s", r.Request.Method, r.uri, err), http.StatusNotFound)
|
|
|
}
|