From 34145c990d4fd9f278f29cdf9c61378a75e9b934 Mon Sep 17 00:00:00 2001 From: ᴜɴᴋɴᴡᴏɴ Date: Sat, 4 Apr 2020 21:14:15 +0800 Subject: lfs: implement HTTP routes (#6035) * Bootstrap with GORM * Fix lint error * Set conn max lifetime to one minute * Fallback to use gorm v1 * Define HTTP routes * Finish authentication * Save token updated * Add docstring * Finish authorization * serveBatch rundown * Define types in lfsutil * Finish Batch * authutil * Finish basic * Formalize response error * Fix lint errors * authutil: add tests * dbutil: add tests * lfsutil: add tests * strutil: add tests * Formalize 401 response --- internal/cmd/web.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'internal/cmd/web.go') diff --git a/internal/cmd/web.go b/internal/cmd/web.go index 84c99184..f26c5a51 100644 --- a/internal/cmd/web.go +++ b/internal/cmd/web.go @@ -41,6 +41,7 @@ import ( "gogs.io/gogs/internal/route/admin" apiv1 "gogs.io/gogs/internal/route/api/v1" "gogs.io/gogs/internal/route/dev" + "gogs.io/gogs/internal/route/lfs" "gogs.io/gogs/internal/route/org" "gogs.io/gogs/internal/route/repo" "gogs.io/gogs/internal/route/user" @@ -648,11 +649,14 @@ func runWeb(c *cli.Context) error { // e.g. with or without ".git" suffix. m.Group("/:reponame([\\d\\w-_\\.]+\\.git$)", func() { m.Get("", ignSignIn, context.RepoAssignment(), context.RepoRef(), repo.Home) - m.Options("/*", ignSignInAndCsrf, repo.HTTPContexter(), repo.HTTP) - m.Route("/*", "GET,POST", ignSignInAndCsrf, repo.HTTPContexter(), repo.HTTP) + + m.Group("/info/lfs", func() { + lfs.RegisterRoutes(m.Router) + }, ignSignInAndCsrf) + + m.Route("/*", "GET,POST,OPTIONS", ignSignInAndCsrf, repo.HTTPContexter(), repo.HTTP) }) - m.Options("/:reponame/*", ignSignInAndCsrf, repo.HTTPContexter(), repo.HTTP) - m.Route("/:reponame/*", "GET,POST", ignSignInAndCsrf, repo.HTTPContexter(), repo.HTTP) + m.Route("/:reponame/*", "GET,POST,OPTIONS", ignSignInAndCsrf, repo.HTTPContexter(), repo.HTTP) }) // ***** END: Repository ***** -- cgit v1.2.3