diff --git a/api/handler.go b/api/handler.go index 07fc578..7abc064 100644 --- a/api/handler.go +++ b/api/handler.go @@ -270,8 +270,8 @@ func GetFileContents(w http.ResponseWriter, r *http.Request) { func GetArchive(w http.ResponseWriter, r *http.Request) { repo := r.URL.Query().Get(":name") - ref := r.URL.Query().Get(":ref") - format := r.URL.Query().Get(":format") + ref := r.URL.Query().Get("ref") + format := r.URL.Query().Get("format") if ref == "" || format == "" || repo == "" { err := fmt.Errorf("Error when trying to obtain archive for ref '%s' (format: %s) of repository '%s' (repository, ref and format are required).", ref, format, repo) http.Error(w, err.Error(), http.StatusBadRequest) diff --git a/api/handler_test.go b/api/handler_test.go index cbb79d9..c15ddf8 100644 --- a/api/handler_test.go +++ b/api/handler_test.go @@ -767,7 +767,7 @@ func (s *S) TestGetFileContentsWhenNoRepository(c *gocheck.C) { } func (s *S) TestGetArchiveWhenNoRef(c *gocheck.C) { - url := "/repository/repo/archive/.zip?:name=repo&:ref=&:format=zip" + url := "/repository/repo/archive?:name=repo&ref=&format=zip" request, err := http.NewRequest("GET", url, nil) c.Assert(err, gocheck.IsNil) recorder := httptest.NewRecorder() @@ -778,7 +778,7 @@ func (s *S) TestGetArchiveWhenNoRef(c *gocheck.C) { } func (s *S) TestGetArchiveWhenNoRepo(c *gocheck.C) { - url := "/repository//archive/master.zip?:name=&:ref=master&:format=zip" + url := "/repository//archive?:name=&ref=master&format=zip" request, err := http.NewRequest("GET", url, nil) c.Assert(err, gocheck.IsNil) recorder := httptest.NewRecorder() @@ -789,7 +789,7 @@ func (s *S) TestGetArchiveWhenNoRepo(c *gocheck.C) { } func (s *S) TestGetArchiveWhenNoFormat(c *gocheck.C) { - url := "/repository/repo/archive/master.?:name=repo&:ref=master&:format=" + url := "/repository/repo/archive?:name=repo&ref=master&format=" request, err := http.NewRequest("GET", url, nil) c.Assert(err, gocheck.IsNil) recorder := httptest.NewRecorder() @@ -800,7 +800,7 @@ func (s *S) TestGetArchiveWhenNoFormat(c *gocheck.C) { } func (s *S) TestGetArchiveWhenCommandFails(c *gocheck.C) { - url := "/repository/repo/archive/master.zip?:name=repo&:ref=master&:format=zip" + url := "/repository/repo/archive?:name=repo&ref=master&format=zip" expected := fmt.Errorf("output error") mockRetriever := repository.MockContentRetriever{ OutputError: expected, @@ -818,7 +818,7 @@ func (s *S) TestGetArchiveWhenCommandFails(c *gocheck.C) { } func (s *S) TestGetArchive(c *gocheck.C) { - url := "/repository/repo/archive/master.zip?:name=repo&:ref=master&:format=zip" + url := "/repository/repo/archive?:name=repo&ref=master&format=zip" expected := "result123" mockRetriever := repository.MockContentRetriever{ ResultContents: []byte(expected), diff --git a/webserver/main.go b/webserver/main.go index 50d4cbb..2c1baa0 100644 --- a/webserver/main.go +++ b/webserver/main.go @@ -45,7 +45,7 @@ For an example conf check gandalf/etc/gandalf.conf file.\n %s` router.Del("/repository/:name", http.HandlerFunc(api.RemoveRepository)) router.Get("/repository/:name", http.HandlerFunc(api.GetRepository)) router.Put("/repository/:name", http.HandlerFunc(api.RenameRepository)) - router.Get("/repository/:name/archive/:ref.:format", http.HandlerFunc(api.GetArchive)) + router.Get("/repository/:name/archive", http.HandlerFunc(api.GetArchive)) router.Get("/repository/:name/contents", http.HandlerFunc(api.GetFileContents)) router.Get("/repository/:name/tree/:path", http.HandlerFunc(api.GetTree)) router.Get("/repository/:name/tree", http.HandlerFunc(api.GetTree))