From 82b78912fc1fa6b68e8059c70f07a54d8418760f Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Tue, 29 Jul 2014 18:11:22 -0400 Subject: [PATCH] Move prefix methods --- pkg/apiserver/apiserver.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/apiserver/apiserver.go b/pkg/apiserver/apiserver.go index 4d68b44fb05..77f7e6c8f8d 100644 --- a/pkg/apiserver/apiserver.go +++ b/pkg/apiserver/apiserver.go @@ -97,14 +97,6 @@ func New(storage map[string]RESTStorage, prefix string) *APIServer { return s } -func (server *APIServer) operationPrefix() string { - return path.Join(server.prefix, "operations") -} - -func (server *APIServer) watchPrefix() string { - return path.Join(server.prefix, "watch") -} - // handleVersionReq writes the server's version information. func (server *APIServer) handleVersionReq(w http.ResponseWriter, req *http.Request) { server.writeRawJSON(http.StatusOK, version.Get(), w) @@ -157,7 +149,7 @@ func (s *APIServer) ServeREST(w http.ResponseWriter, req *http.Request) { func (s *APIServer) write(statusCode int, object interface{}, w http.ResponseWriter) { output, err := api.Encode(object) if err != nil { - s.error(err, w) + internalError(err, w) return } w.Header().Set("Content-Type", "application/json") @@ -338,6 +330,10 @@ func (s *APIServer) handleREST(parts []string, req *http.Request, w http.Respons } } +func (s *APIServer) operationPrefix() string { + return path.Join(s.prefix, "operations") +} + func (s *APIServer) handleOperationRequest(w http.ResponseWriter, req *http.Request) { opPrefix := s.operationPrefix() if !strings.HasPrefix(req.URL.Path, opPrefix) { @@ -375,6 +371,10 @@ func (s *APIServer) handleOperationRequest(w http.ResponseWriter, req *http.Requ } } +func (s *APIServer) watchPrefix() string { + return path.Join(s.prefix, "watch") +} + func (s *APIServer) handleWatch(w http.ResponseWriter, req *http.Request) { prefix := s.watchPrefix() if !strings.HasPrefix(req.URL.Path, prefix) {