diff options
author | Bharat Nallan <bharatnc@gmail.com> | 2020-03-13 07:37:42 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-13 22:37:42 +0800 |
commit | 268c692efde428fa2a00aff0860b093b2f4dc59e (patch) | |
tree | 776d9564b49de367df37e6b73cb36acc0ad6ad60 /internal/route/api | |
parent | 434f1ec542cc6dab6b2709e3a6fab261bdad4c7b (diff) |
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.
Diffstat (limited to 'internal/route/api')
-rw-r--r-- | internal/route/api/v1/api.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/internal/route/api/v1/api.go b/internal/route/api/v1/api.go index b54a6dff..98394049 100644 --- a/internal/route/api/v1/api.go +++ b/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) |