diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2014-03-22 00:48:26 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2014-03-22 00:48:26 +0800 |
commit | efdaf6ee1536f043d9e242dc16a096c99ec1bfda (patch) | |
tree | c2aac787780b7a8e1925e0b4536ae735f7d3680b /routers | |
parent | 5cb2d3d2e233def07d6956af47dfc49acc45c7e6 (diff) | |
download | gitea-efdaf6ee1536f043d9e242dc16a096c99ec1bfda.tar.gz gitea-efdaf6ee1536f043d9e242dc16a096c99ec1bfda.zip |
add http protocol clone support
Diffstat (limited to 'routers')
-rw-r--r-- | routers/repo/single.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/routers/repo/single.go b/routers/repo/single.go index c10d30a7d6..064150a234 100644 --- a/routers/repo/single.go +++ b/routers/repo/single.go @@ -5,11 +5,13 @@ package repo import ( + "path" "strings" "github.com/codegangsta/martini" "github.com/gogits/git" + "github.com/gogits/webdav" "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/base" @@ -181,6 +183,29 @@ func Single(ctx *middleware.Context, params martini.Params) { ctx.HTML(200, "repo/single", ctx.Data) } +func Http(ctx *middleware.Context, params martini.Params) { + /*if !ctx.Repo.IsValid { + return + }*/ + + // TODO: access check + + username := params["username"] + reponame := params["reponame"] + if strings.HasSuffix(reponame, ".git") { + reponame = reponame[:len(reponame)-4] + } + + prefix := path.Join("/", username, params["reponame"]) + server := &webdav.Server{ + Fs: webdav.Dir(models.RepoPath(username, reponame)), + TrimPrefix: prefix, + Listings: true, + } + + server.ServeHTTP(ctx.ResponseWriter, ctx.Req) +} + func Setting(ctx *middleware.Context, params martini.Params) { if !ctx.Repo.IsOwner { ctx.Error(404) |