소스 검색

api: group "/contents" with "" and "/*" #5985 (#5986)

This PR groups the contents api endpoint with both `""` and `/*` as
valid URL patterns.

When `""` is the URL pattern, this means that no repo path has'nt been
provided, in which case the path would be the default repo path.

When  `"/*"` is the URL pattern, then this would return the contents at
the specified path if it's valid.

Github API v3 is conformant to this behavior and have verified it
locally.
Bharat Nallan 4 년 전
부모
커밋
268c692efd
1개의 변경된 파일4개의 추가작업 그리고 1개의 파일을 삭제
  1. 4 1
      internal/route/api/v1/api.go

+ 4 - 1
internal/route/api/v1/api.go

@@ -271,7 +271,10 @@ func RegisterRoutes(m *macaron.Macaron) {
 				}, reqRepoAdmin())
 
 				m.Get("/raw/*", context.RepoRef(), repo.GetRawFile)
-				m.Get("/contents/*", repo.GetContents)
+				m.Group("/contents", func() {
+					m.Get("", repo.GetContents)
+					m.Get("/*", repo.GetContents)
+				})
 				m.Get("/archive/*", repo.GetArchive)
 				m.Group("/git/trees", func() {
 					m.Get("/:sha", repo.GetRepoGitTree)