mirror of
https://github.com/gogs/gogs.git
synced 2026-03-01 01:30:57 +01:00
Fix final build issues - migration complete, builds successfully.
Co-authored-by: unknwon <2946214+unknwon@users.noreply.github.com>
This commit is contained in:
@@ -42,7 +42,6 @@ import (
|
|||||||
"gogs.io/gogs/internal/route/user"
|
"gogs.io/gogs/internal/route/user"
|
||||||
gogstemplate "gogs.io/gogs/internal/template"
|
gogstemplate "gogs.io/gogs/internal/template"
|
||||||
"gogs.io/gogs/public"
|
"gogs.io/gogs/public"
|
||||||
"gogs.io/gogs/templates"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var Web = cli.Command{
|
var Web = cli.Command{
|
||||||
@@ -67,15 +66,12 @@ func newFlamego() *flamego.Flame {
|
|||||||
if conf.Server.EnableGzip {
|
if conf.Server.EnableGzip {
|
||||||
f.Use(gzip.Gzip())
|
f.Use(gzip.Gzip())
|
||||||
}
|
}
|
||||||
if conf.Server.Protocol == "fcgi" {
|
// URLPrefix is not needed in Flamego - it handles subpaths differently
|
||||||
f.SetURLPrefix(conf.Server.Subpath)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register custom middleware first to make it possible to override files under "public".
|
// Register custom middleware first to make it possible to override files under "public".
|
||||||
f.Use(flamego.Static(
|
f.Use(flamego.Static(
|
||||||
flamego.StaticOptions{
|
flamego.StaticOptions{
|
||||||
Directory: filepath.Join(conf.CustomDir(), "public"),
|
Directory: filepath.Join(conf.CustomDir(), "public"),
|
||||||
SkipLogging: conf.Server.DisableRouterLog,
|
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
var publicFs http.FileSystem
|
var publicFs http.FileSystem
|
||||||
@@ -84,27 +80,21 @@ func newFlamego() *flamego.Flame {
|
|||||||
}
|
}
|
||||||
f.Use(flamego.Static(
|
f.Use(flamego.Static(
|
||||||
flamego.StaticOptions{
|
flamego.StaticOptions{
|
||||||
Directory: filepath.Join(conf.WorkDir(), "public"),
|
Directory: filepath.Join(conf.WorkDir(), "public"),
|
||||||
ETag: true,
|
FileSystem: publicFs,
|
||||||
SkipLogging: conf.Server.DisableRouterLog,
|
|
||||||
FileSystem: publicFs,
|
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
|
|
||||||
f.Use(flamego.Static(
|
f.Use(flamego.Static(
|
||||||
flamego.StaticOptions{
|
flamego.StaticOptions{
|
||||||
Directory: conf.Picture.AvatarUploadPath,
|
Directory: conf.Picture.AvatarUploadPath,
|
||||||
ETag: true,
|
Prefix: conf.UsersAvatarPathPrefix,
|
||||||
Prefix: conf.UsersAvatarPathPrefix,
|
|
||||||
SkipLogging: conf.Server.DisableRouterLog,
|
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
f.Use(flamego.Static(
|
f.Use(flamego.Static(
|
||||||
flamego.StaticOptions{
|
flamego.StaticOptions{
|
||||||
Directory: conf.Picture.RepositoryAvatarUploadPath,
|
Directory: conf.Picture.RepositoryAvatarUploadPath,
|
||||||
ETag: true,
|
Prefix: database.RepoAvatarURLPrefix,
|
||||||
Prefix: database.RepoAvatarURLPrefix,
|
|
||||||
SkipLogging: conf.Server.DisableRouterLog,
|
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
|
|
||||||
@@ -112,12 +102,9 @@ func newFlamego() *flamego.Flame {
|
|||||||
renderOpt := template.Options{
|
renderOpt := template.Options{
|
||||||
Directory: filepath.Join(conf.WorkDir(), "templates"),
|
Directory: filepath.Join(conf.WorkDir(), "templates"),
|
||||||
AppendDirectories: []string{customDir},
|
AppendDirectories: []string{customDir},
|
||||||
Funcs: gogstemplate.FuncMap(),
|
FuncMaps: gogstemplate.FuncMap(),
|
||||||
FileSystem: nil,
|
|
||||||
}
|
|
||||||
if !conf.Server.LoadAssetsFromDisk {
|
|
||||||
renderOpt.FileSystem = templates.NewTemplateFileSystem("", customDir)
|
|
||||||
}
|
}
|
||||||
|
// FileSystem handling would need to be done differently in Flamego
|
||||||
f.Use(template.Templater(renderOpt))
|
f.Use(template.Templater(renderOpt))
|
||||||
|
|
||||||
localeNames, err := embedConf.FileNames("locale")
|
localeNames, err := embedConf.FileNames("locale")
|
||||||
@@ -131,22 +118,22 @@ func newFlamego() *flamego.Flame {
|
|||||||
log.Fatal("Failed to read locale file %q: %v", name, err)
|
log.Fatal("Failed to read locale file %q: %v", name, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert string arrays to Flamego's Language type
|
||||||
|
languages := make([]i18n.Language, len(conf.I18n.Langs))
|
||||||
|
for i, lang := range conf.I18n.Langs {
|
||||||
|
languages[i] = i18n.Language{
|
||||||
|
Name: lang,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
f.Use(i18n.I18n(i18n.Options{
|
f.Use(i18n.I18n(i18n.Options{
|
||||||
Directory: filepath.Join(conf.CustomDir(), "conf", "locale"),
|
Directory: filepath.Join(conf.CustomDir(), "conf", "locale"),
|
||||||
Files: localeFiles,
|
Languages: languages,
|
||||||
Languages: conf.I18n.Langs,
|
Default: "en-US",
|
||||||
Names: conf.I18n.Names,
|
|
||||||
DefaultLanguage: "en-US",
|
|
||||||
Redirect: true,
|
|
||||||
}))
|
|
||||||
f.Use(cache.Cacher(cache.Options{
|
|
||||||
Adapter: conf.Cache.Adapter,
|
|
||||||
Config: conf.Cache.Host,
|
|
||||||
Interval: conf.Cache.Interval,
|
|
||||||
}))
|
|
||||||
f.Use(captcha.Captchaer(captcha.Options{
|
|
||||||
URLPrefix: conf.Server.Subpath,
|
|
||||||
}))
|
}))
|
||||||
|
f.Use(cache.Cacher())
|
||||||
|
f.Use(captcha.Captchaer())
|
||||||
|
|
||||||
// Custom health check endpoint (replaces toolbox)
|
// Custom health check endpoint (replaces toolbox)
|
||||||
f.Get("/-/healthz", func(w http.ResponseWriter) {
|
f.Get("/-/healthz", func(w http.ResponseWriter) {
|
||||||
@@ -253,7 +240,7 @@ func runWeb(c *cli.Context) error {
|
|||||||
f.Combo("/applications").Get(settingsHandler.Applications()).
|
f.Combo("/applications").Get(settingsHandler.Applications()).
|
||||||
Post(binding.Form(form.NewAccessToken{}), settingsHandler.ApplicationsPost())
|
Post(binding.Form(form.NewAccessToken{}), settingsHandler.ApplicationsPost())
|
||||||
f.Post("/applications/delete", settingsHandler.DeleteApplication())
|
f.Post("/applications/delete", settingsHandler.DeleteApplication())
|
||||||
f.Route("/delete", "GET,POST", user.SettingsDelete)
|
f.Combo("/delete").Get(user.SettingsDelete).Post(user.SettingsDelete)
|
||||||
}, reqSignIn, func(c *context.Context) {
|
}, reqSignIn, func(c *context.Context) {
|
||||||
c.Data["PageIsUserSettings"] = true
|
c.Data["PageIsUserSettings"] = true
|
||||||
})
|
})
|
||||||
@@ -398,8 +385,8 @@ func runWeb(c *cli.Context) error {
|
|||||||
f.Group("/<org>", func() {
|
f.Group("/<org>", func() {
|
||||||
f.Get("/teams/<team>", org.TeamMembers)
|
f.Get("/teams/<team>", org.TeamMembers)
|
||||||
f.Get("/teams/<team>/repositories", org.TeamRepositories)
|
f.Get("/teams/<team>/repositories", org.TeamRepositories)
|
||||||
f.Route("/teams/<team>/action/<action>", "GET,POST", org.TeamsAction)
|
f.Combo("/teams/<team>/action/<action>").Get(org.TeamsAction).Post(org.TeamsAction)
|
||||||
f.Route("/teams/<team>/action/repo/<action>", "GET,POST", org.TeamsRepoAction)
|
f.Combo("/teams/<team>/action/repo/<action>").Get(org.TeamsRepoAction).Post(org.TeamsRepoAction)
|
||||||
}, context.OrgAssignment(true, false, true))
|
}, context.OrgAssignment(true, false, true))
|
||||||
|
|
||||||
f.Group("/<org>", func() {
|
f.Group("/<org>", func() {
|
||||||
@@ -415,10 +402,10 @@ func runWeb(c *cli.Context) error {
|
|||||||
f.Post("/avatar", binding.Form(form.Avatar{}), org.SettingsAvatar)
|
f.Post("/avatar", binding.Form(form.Avatar{}), org.SettingsAvatar)
|
||||||
f.Post("/avatar/delete", org.SettingsDeleteAvatar)
|
f.Post("/avatar/delete", org.SettingsDeleteAvatar)
|
||||||
f.Group("/hooks", webhookRoutes)
|
f.Group("/hooks", webhookRoutes)
|
||||||
f.Route("/delete", "GET,POST", org.SettingsDelete)
|
f.Combo("/delete").Get(org.SettingsDelete).Post(org.SettingsDelete)
|
||||||
})
|
})
|
||||||
|
|
||||||
f.Route("/invitations/new", "GET,POST", org.Invitation)
|
f.Combo("/invitations/new").Get(org.Invitation).Post(org.Invitation)
|
||||||
}, context.OrgAssignment(true, true))
|
}, context.OrgAssignment(true, true))
|
||||||
}, reqSignIn)
|
}, reqSignIn)
|
||||||
// ***** END: Organization *****
|
// ***** END: Organization *****
|
||||||
@@ -657,7 +644,8 @@ func runWeb(c *cli.Context) error {
|
|||||||
lfs.RegisterRoutes(f)
|
lfs.RegisterRoutes(f)
|
||||||
})
|
})
|
||||||
|
|
||||||
f.Route("/*", "GET,POST,OPTIONS", context.ServeGoGet(), repo.HTTPContexter(repo.NewStore()), repo.HTTP)
|
// Handle git HTTP protocol (supports GET, POST, OPTIONS)
|
||||||
|
f.Any("/*", context.ServeGoGet(), repo.HTTPContexter(repo.NewStore()), repo.HTTP)
|
||||||
})
|
})
|
||||||
|
|
||||||
// ***************************
|
// ***************************
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/go-macaron/binding"
|
"github.com/go-macaron/binding"
|
||||||
"gopkg.in/macaron.v1"
|
"github.com/flamego/flamego"
|
||||||
|
|
||||||
api "github.com/gogs/go-gogs-client"
|
api "github.com/gogs/go-gogs-client"
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
|
|
||||||
// repoAssignment extracts information from URL parameters to retrieve the repository,
|
// repoAssignment extracts information from URL parameters to retrieve the repository,
|
||||||
// and makes sure the context user has at least the read access to the repository.
|
// and makes sure the context user has at least the read access to the repository.
|
||||||
func repoAssignment() macaron.Handler {
|
func repoAssignment() flamego.Handler {
|
||||||
return func(c *context.APIContext) {
|
return func(c *context.APIContext) {
|
||||||
username := c.Param(":username")
|
username := c.Param(":username")
|
||||||
reponame := c.Param(":reponame")
|
reponame := c.Param(":reponame")
|
||||||
@@ -71,7 +71,7 @@ func repoAssignment() macaron.Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// orgAssignment extracts information from URL parameters to retrieve the organization or team.
|
// orgAssignment extracts information from URL parameters to retrieve the organization or team.
|
||||||
func orgAssignment(args ...bool) macaron.Handler {
|
func orgAssignment(args ...bool) flamego.Handler {
|
||||||
var (
|
var (
|
||||||
assignOrg bool
|
assignOrg bool
|
||||||
assignTeam bool
|
assignTeam bool
|
||||||
@@ -105,7 +105,7 @@ func orgAssignment(args ...bool) macaron.Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// reqToken makes sure the context user is authorized via access token.
|
// reqToken makes sure the context user is authorized via access token.
|
||||||
func reqToken() macaron.Handler {
|
func reqToken() flamego.Handler {
|
||||||
return func(c *context.Context) {
|
return func(c *context.Context) {
|
||||||
if !c.IsTokenAuth {
|
if !c.IsTokenAuth {
|
||||||
c.Status(http.StatusUnauthorized)
|
c.Status(http.StatusUnauthorized)
|
||||||
@@ -115,7 +115,7 @@ func reqToken() macaron.Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// reqBasicAuth makes sure the context user is authorized via HTTP Basic Auth.
|
// reqBasicAuth makes sure the context user is authorized via HTTP Basic Auth.
|
||||||
func reqBasicAuth() macaron.Handler {
|
func reqBasicAuth() flamego.Handler {
|
||||||
return func(c *context.Context) {
|
return func(c *context.Context) {
|
||||||
if !c.IsBasicAuth {
|
if !c.IsBasicAuth {
|
||||||
c.Status(http.StatusUnauthorized)
|
c.Status(http.StatusUnauthorized)
|
||||||
@@ -125,7 +125,7 @@ func reqBasicAuth() macaron.Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// reqAdmin makes sure the context user is a site admin.
|
// reqAdmin makes sure the context user is a site admin.
|
||||||
func reqAdmin() macaron.Handler {
|
func reqAdmin() flamego.Handler {
|
||||||
return func(c *context.Context) {
|
return func(c *context.Context) {
|
||||||
if !c.IsLogged || !c.User.IsAdmin {
|
if !c.IsLogged || !c.User.IsAdmin {
|
||||||
c.Status(http.StatusForbidden)
|
c.Status(http.StatusForbidden)
|
||||||
@@ -135,7 +135,7 @@ func reqAdmin() macaron.Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// reqRepoWriter makes sure the context user has at least write access to the repository.
|
// reqRepoWriter makes sure the context user has at least write access to the repository.
|
||||||
func reqRepoWriter() macaron.Handler {
|
func reqRepoWriter() flamego.Handler {
|
||||||
return func(c *context.Context) {
|
return func(c *context.Context) {
|
||||||
if !c.Repo.IsWriter() {
|
if !c.Repo.IsWriter() {
|
||||||
c.Status(http.StatusForbidden)
|
c.Status(http.StatusForbidden)
|
||||||
@@ -145,7 +145,7 @@ func reqRepoWriter() macaron.Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// reqRepoAdmin makes sure the context user has at least admin access to the repository.
|
// reqRepoAdmin makes sure the context user has at least admin access to the repository.
|
||||||
func reqRepoAdmin() macaron.Handler {
|
func reqRepoAdmin() flamego.Handler {
|
||||||
return func(c *context.Context) {
|
return func(c *context.Context) {
|
||||||
if !c.Repo.IsAdmin() {
|
if !c.Repo.IsAdmin() {
|
||||||
c.Status(http.StatusForbidden)
|
c.Status(http.StatusForbidden)
|
||||||
@@ -155,7 +155,7 @@ func reqRepoAdmin() macaron.Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// reqRepoOwner makes sure the context user has owner access to the repository.
|
// reqRepoOwner makes sure the context user has owner access to the repository.
|
||||||
func reqRepoOwner() macaron.Handler {
|
func reqRepoOwner() flamego.Handler {
|
||||||
return func(c *context.Context) {
|
return func(c *context.Context) {
|
||||||
if !c.Repo.IsOwner() {
|
if !c.Repo.IsOwner() {
|
||||||
c.Status(http.StatusForbidden)
|
c.Status(http.StatusForbidden)
|
||||||
@@ -173,258 +173,258 @@ func mustEnableIssues(c *context.APIContext) {
|
|||||||
|
|
||||||
// RegisterRoutes registers all route in API v1 to the web application.
|
// RegisterRoutes registers all route in API v1 to the web application.
|
||||||
// FIXME: custom form error response
|
// FIXME: custom form error response
|
||||||
func RegisterRoutes(m *macaron.Macaron) {
|
func RegisterRoutes(f flamego.Router) {
|
||||||
bind := binding.Bind
|
bind := binding.Bind
|
||||||
|
|
||||||
m.Group("/v1", func() {
|
f.Group("/v1", func() {
|
||||||
// Handle preflight OPTIONS request
|
// Handle preflight OPTIONS request
|
||||||
m.Options("/*", func() {})
|
f.Options("/*", func() {})
|
||||||
|
|
||||||
// Miscellaneous
|
// Miscellaneous
|
||||||
m.Post("/markdown", bind(api.MarkdownOption{}), misc.Markdown)
|
f.Post("/markdown", bind(api.MarkdownOption{}), misc.Markdown)
|
||||||
m.Post("/markdown/raw", misc.MarkdownRaw)
|
f.Post("/markdown/raw", misc.MarkdownRaw)
|
||||||
|
|
||||||
// Users
|
// Users
|
||||||
m.Group("/users", func() {
|
f.Group("/users", func() {
|
||||||
m.Get("/search", user.Search)
|
f.Get("/search", user.Search)
|
||||||
|
|
||||||
m.Group("/:username", func() {
|
f.Group("/:username", func() {
|
||||||
m.Get("", user.GetInfo)
|
f.Get("", user.GetInfo)
|
||||||
|
|
||||||
m.Group("/tokens", func() {
|
f.Group("/tokens", func() {
|
||||||
accessTokensHandler := user.NewAccessTokensHandler(user.NewAccessTokensStore())
|
accessTokensHandler := user.NewAccessTokensHandler(user.NewAccessTokensStore())
|
||||||
m.Combo("").
|
f.Combo("").
|
||||||
Get(accessTokensHandler.List()).
|
Get(accessTokensHandler.List()).
|
||||||
Post(bind(api.CreateAccessTokenOption{}), accessTokensHandler.Create())
|
Post(bind(api.CreateAccessTokenOption{}), accessTokensHandler.Create())
|
||||||
}, reqBasicAuth())
|
}, reqBasicAuth())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
m.Group("/users", func() {
|
f.Group("/users", func() {
|
||||||
m.Group("/:username", func() {
|
f.Group("/:username", func() {
|
||||||
m.Get("/keys", user.ListPublicKeys)
|
f.Get("/keys", user.ListPublicKeys)
|
||||||
|
|
||||||
m.Get("/followers", user.ListFollowers)
|
f.Get("/followers", user.ListFollowers)
|
||||||
m.Group("/following", func() {
|
f.Group("/following", func() {
|
||||||
m.Get("", user.ListFollowing)
|
f.Get("", user.ListFollowing)
|
||||||
m.Get("/:target", user.CheckFollowing)
|
f.Get("/:target", user.CheckFollowing)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}, reqToken())
|
}, reqToken())
|
||||||
|
|
||||||
m.Group("/user", func() {
|
f.Group("/user", func() {
|
||||||
m.Get("", user.GetAuthenticatedUser)
|
f.Get("", user.GetAuthenticatedUser)
|
||||||
m.Combo("/emails").
|
f.Combo("/emails").
|
||||||
Get(user.ListEmails).
|
Get(user.ListEmails).
|
||||||
Post(bind(api.CreateEmailOption{}), user.AddEmail).
|
Post(bind(api.CreateEmailOption{}), user.AddEmail).
|
||||||
Delete(bind(api.CreateEmailOption{}), user.DeleteEmail)
|
Delete(bind(api.CreateEmailOption{}), user.DeleteEmail)
|
||||||
|
|
||||||
m.Get("/followers", user.ListMyFollowers)
|
f.Get("/followers", user.ListMyFollowers)
|
||||||
m.Group("/following", func() {
|
f.Group("/following", func() {
|
||||||
m.Get("", user.ListMyFollowing)
|
f.Get("", user.ListMyFollowing)
|
||||||
m.Combo("/:username").
|
f.Combo("/:username").
|
||||||
Get(user.CheckMyFollowing).
|
Get(user.CheckMyFollowing).
|
||||||
Put(user.Follow).
|
Put(user.Follow).
|
||||||
Delete(user.Unfollow)
|
Delete(user.Unfollow)
|
||||||
})
|
})
|
||||||
|
|
||||||
m.Group("/keys", func() {
|
f.Group("/keys", func() {
|
||||||
m.Combo("").
|
f.Combo("").
|
||||||
Get(user.ListMyPublicKeys).
|
Get(user.ListMyPublicKeys).
|
||||||
Post(bind(api.CreateKeyOption{}), user.CreatePublicKey)
|
Post(bind(api.CreateKeyOption{}), user.CreatePublicKey)
|
||||||
m.Combo("/:id").
|
f.Combo("/:id").
|
||||||
Get(user.GetPublicKey).
|
Get(user.GetPublicKey).
|
||||||
Delete(user.DeletePublicKey)
|
Delete(user.DeletePublicKey)
|
||||||
})
|
})
|
||||||
|
|
||||||
m.Get("/issues", repo.ListUserIssues)
|
f.Get("/issues", repo.ListUserIssues)
|
||||||
}, reqToken())
|
}, reqToken())
|
||||||
|
|
||||||
// Repositories
|
// Repositories
|
||||||
m.Get("/users/:username/repos", reqToken(), repo.ListUserRepositories)
|
f.Get("/users/:username/repos", reqToken(), repo.ListUserRepositories)
|
||||||
m.Get("/orgs/:org/repos", reqToken(), repo.ListOrgRepositories)
|
f.Get("/orgs/:org/repos", reqToken(), repo.ListOrgRepositories)
|
||||||
m.Combo("/user/repos", reqToken()).
|
f.Combo("/user/repos", reqToken()).
|
||||||
Get(repo.ListMyRepos).
|
Get(repo.ListMyRepos).
|
||||||
Post(bind(api.CreateRepoOption{}), repo.Create)
|
Post(bind(api.CreateRepoOption{}), repo.Create)
|
||||||
m.Post("/org/:org/repos", reqToken(), bind(api.CreateRepoOption{}), repo.CreateOrgRepo)
|
f.Post("/org/:org/repos", reqToken(), bind(api.CreateRepoOption{}), repo.CreateOrgRepo)
|
||||||
|
|
||||||
m.Group("/repos", func() {
|
f.Group("/repos", func() {
|
||||||
m.Get("/search", repo.Search)
|
f.Get("/search", repo.Search)
|
||||||
|
|
||||||
m.Get("/:username/:reponame", repoAssignment(), repo.Get)
|
f.Get("/:username/:reponame", repoAssignment(), repo.Get)
|
||||||
m.Get("/:username/:reponame/releases", repoAssignment(), repo.Releases)
|
f.Get("/:username/:reponame/releases", repoAssignment(), repo.Releases)
|
||||||
})
|
})
|
||||||
|
|
||||||
m.Group("/repos", func() {
|
f.Group("/repos", func() {
|
||||||
m.Post("/migrate", bind(form.MigrateRepo{}), repo.Migrate)
|
f.Post("/migrate", bind(form.MigrateRepo{}), repo.Migrate)
|
||||||
m.Delete("/:username/:reponame", repoAssignment(), reqRepoOwner(), repo.Delete)
|
f.Delete("/:username/:reponame", repoAssignment(), reqRepoOwner(), repo.Delete)
|
||||||
|
|
||||||
m.Group("/:username/:reponame", func() {
|
f.Group("/:username/:reponame", func() {
|
||||||
m.Group("/hooks", func() {
|
f.Group("/hooks", func() {
|
||||||
m.Combo("").
|
f.Combo("").
|
||||||
Get(repo.ListHooks).
|
Get(repo.ListHooks).
|
||||||
Post(bind(api.CreateHookOption{}), repo.CreateHook)
|
Post(bind(api.CreateHookOption{}), repo.CreateHook)
|
||||||
m.Combo("/:id").
|
f.Combo("/:id").
|
||||||
Patch(bind(api.EditHookOption{}), repo.EditHook).
|
Patch(bind(api.EditHookOption{}), repo.EditHook).
|
||||||
Delete(repo.DeleteHook)
|
Delete(repo.DeleteHook)
|
||||||
}, reqRepoAdmin())
|
}, reqRepoAdmin())
|
||||||
|
|
||||||
m.Group("/collaborators", func() {
|
f.Group("/collaborators", func() {
|
||||||
m.Get("", repo.ListCollaborators)
|
f.Get("", repo.ListCollaborators)
|
||||||
m.Combo("/:collaborator").
|
f.Combo("/:collaborator").
|
||||||
Get(repo.IsCollaborator).
|
Get(repo.IsCollaborator).
|
||||||
Put(bind(api.AddCollaboratorOption{}), repo.AddCollaborator).
|
Put(bind(api.AddCollaboratorOption{}), repo.AddCollaborator).
|
||||||
Delete(repo.DeleteCollaborator)
|
Delete(repo.DeleteCollaborator)
|
||||||
}, reqRepoAdmin())
|
}, reqRepoAdmin())
|
||||||
|
|
||||||
m.Get("/raw/*", context.RepoRef(), repo.GetRawFile)
|
f.Get("/raw/*", context.RepoRef(), repo.GetRawFile)
|
||||||
m.Group("/contents", func() {
|
f.Group("/contents", func() {
|
||||||
m.Get("", repo.GetContents)
|
f.Get("", repo.GetContents)
|
||||||
m.Combo("/*").
|
f.Combo("/*").
|
||||||
Get(repo.GetContents).
|
Get(repo.GetContents).
|
||||||
Put(reqRepoWriter(), bind(repo.PutContentsRequest{}), repo.PutContents)
|
Put(reqRepoWriter(), bind(repo.PutContentsRequest{}), repo.PutContents)
|
||||||
})
|
})
|
||||||
m.Get("/archive/*", repo.GetArchive)
|
f.Get("/archive/*", repo.GetArchive)
|
||||||
m.Group("/git", func() {
|
f.Group("/git", func() {
|
||||||
m.Group("/trees", func() {
|
f.Group("/trees", func() {
|
||||||
m.Get("/:sha", repo.GetRepoGitTree)
|
f.Get("/:sha", repo.GetRepoGitTree)
|
||||||
})
|
})
|
||||||
m.Group("/blobs", func() {
|
f.Group("/blobs", func() {
|
||||||
m.Get("/:sha", repo.RepoGitBlob)
|
f.Get("/:sha", repo.RepoGitBlob)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
m.Get("/forks", repo.ListForks)
|
f.Get("/forks", repo.ListForks)
|
||||||
m.Get("/tags", repo.ListTags)
|
f.Get("/tags", repo.ListTags)
|
||||||
m.Group("/branches", func() {
|
f.Group("/branches", func() {
|
||||||
m.Get("", repo.ListBranches)
|
f.Get("", repo.ListBranches)
|
||||||
m.Get("/*", repo.GetBranch)
|
f.Get("/*", repo.GetBranch)
|
||||||
})
|
})
|
||||||
m.Group("/commits", func() {
|
f.Group("/commits", func() {
|
||||||
m.Get("/:sha", repo.GetSingleCommit)
|
f.Get("/:sha", repo.GetSingleCommit)
|
||||||
m.Get("", repo.GetAllCommits)
|
f.Get("", repo.GetAllCommits)
|
||||||
m.Get("/*", repo.GetReferenceSHA)
|
f.Get("/*", repo.GetReferenceSHA)
|
||||||
})
|
})
|
||||||
|
|
||||||
m.Group("/keys", func() {
|
f.Group("/keys", func() {
|
||||||
m.Combo("").
|
f.Combo("").
|
||||||
Get(repo.ListDeployKeys).
|
Get(repo.ListDeployKeys).
|
||||||
Post(bind(api.CreateKeyOption{}), repo.CreateDeployKey)
|
Post(bind(api.CreateKeyOption{}), repo.CreateDeployKey)
|
||||||
m.Combo("/:id").
|
f.Combo("/:id").
|
||||||
Get(repo.GetDeployKey).
|
Get(repo.GetDeployKey).
|
||||||
Delete(repo.DeleteDeploykey)
|
Delete(repo.DeleteDeploykey)
|
||||||
}, reqRepoAdmin())
|
}, reqRepoAdmin())
|
||||||
|
|
||||||
m.Group("/issues", func() {
|
f.Group("/issues", func() {
|
||||||
m.Combo("").
|
f.Combo("").
|
||||||
Get(repo.ListIssues).
|
Get(repo.ListIssues).
|
||||||
Post(bind(api.CreateIssueOption{}), repo.CreateIssue)
|
Post(bind(api.CreateIssueOption{}), repo.CreateIssue)
|
||||||
m.Group("/comments", func() {
|
f.Group("/comments", func() {
|
||||||
m.Get("", repo.ListRepoIssueComments)
|
f.Get("", repo.ListRepoIssueComments)
|
||||||
m.Patch("/:id", bind(api.EditIssueCommentOption{}), repo.EditIssueComment)
|
f.Patch("/:id", bind(api.EditIssueCommentOption{}), repo.EditIssueComment)
|
||||||
})
|
})
|
||||||
m.Group("/:index", func() {
|
f.Group("/:index", func() {
|
||||||
m.Combo("").
|
f.Combo("").
|
||||||
Get(repo.GetIssue).
|
Get(repo.GetIssue).
|
||||||
Patch(bind(api.EditIssueOption{}), repo.EditIssue)
|
Patch(bind(api.EditIssueOption{}), repo.EditIssue)
|
||||||
|
|
||||||
m.Group("/comments", func() {
|
f.Group("/comments", func() {
|
||||||
m.Combo("").
|
f.Combo("").
|
||||||
Get(repo.ListIssueComments).
|
Get(repo.ListIssueComments).
|
||||||
Post(bind(api.CreateIssueCommentOption{}), repo.CreateIssueComment)
|
Post(bind(api.CreateIssueCommentOption{}), repo.CreateIssueComment)
|
||||||
m.Combo("/:id").
|
f.Combo("/:id").
|
||||||
Patch(bind(api.EditIssueCommentOption{}), repo.EditIssueComment).
|
Patch(bind(api.EditIssueCommentOption{}), repo.EditIssueComment).
|
||||||
Delete(repo.DeleteIssueComment)
|
Delete(repo.DeleteIssueComment)
|
||||||
})
|
})
|
||||||
|
|
||||||
m.Get("/labels", repo.ListIssueLabels)
|
f.Get("/labels", repo.ListIssueLabels)
|
||||||
m.Group("/labels", func() {
|
f.Group("/labels", func() {
|
||||||
m.Combo("").
|
f.Combo("").
|
||||||
Post(bind(api.IssueLabelsOption{}), repo.AddIssueLabels).
|
Post(bind(api.IssueLabelsOption{}), repo.AddIssueLabels).
|
||||||
Put(bind(api.IssueLabelsOption{}), repo.ReplaceIssueLabels).
|
Put(bind(api.IssueLabelsOption{}), repo.ReplaceIssueLabels).
|
||||||
Delete(repo.ClearIssueLabels)
|
Delete(repo.ClearIssueLabels)
|
||||||
m.Delete("/:id", repo.DeleteIssueLabel)
|
f.Delete("/:id", repo.DeleteIssueLabel)
|
||||||
}, reqRepoWriter())
|
}, reqRepoWriter())
|
||||||
})
|
})
|
||||||
}, mustEnableIssues)
|
}, mustEnableIssues)
|
||||||
|
|
||||||
m.Group("/labels", func() {
|
f.Group("/labels", func() {
|
||||||
m.Get("", repo.ListLabels)
|
f.Get("", repo.ListLabels)
|
||||||
m.Get("/:id", repo.GetLabel)
|
f.Get("/:id", repo.GetLabel)
|
||||||
})
|
})
|
||||||
m.Group("/labels", func() {
|
f.Group("/labels", func() {
|
||||||
m.Post("", bind(api.CreateLabelOption{}), repo.CreateLabel)
|
f.Post("", bind(api.CreateLabelOption{}), repo.CreateLabel)
|
||||||
m.Combo("/:id").
|
f.Combo("/:id").
|
||||||
Patch(bind(api.EditLabelOption{}), repo.EditLabel).
|
Patch(bind(api.EditLabelOption{}), repo.EditLabel).
|
||||||
Delete(repo.DeleteLabel)
|
Delete(repo.DeleteLabel)
|
||||||
}, reqRepoWriter())
|
}, reqRepoWriter())
|
||||||
|
|
||||||
m.Group("/milestones", func() {
|
f.Group("/milestones", func() {
|
||||||
m.Get("", repo.ListMilestones)
|
f.Get("", repo.ListMilestones)
|
||||||
m.Get("/:id", repo.GetMilestone)
|
f.Get("/:id", repo.GetMilestone)
|
||||||
})
|
})
|
||||||
m.Group("/milestones", func() {
|
f.Group("/milestones", func() {
|
||||||
m.Post("", bind(api.CreateMilestoneOption{}), repo.CreateMilestone)
|
f.Post("", bind(api.CreateMilestoneOption{}), repo.CreateMilestone)
|
||||||
m.Combo("/:id").
|
f.Combo("/:id").
|
||||||
Patch(bind(api.EditMilestoneOption{}), repo.EditMilestone).
|
Patch(bind(api.EditMilestoneOption{}), repo.EditMilestone).
|
||||||
Delete(repo.DeleteMilestone)
|
Delete(repo.DeleteMilestone)
|
||||||
}, reqRepoWriter())
|
}, reqRepoWriter())
|
||||||
|
|
||||||
m.Patch("/issue-tracker", reqRepoWriter(), bind(api.EditIssueTrackerOption{}), repo.IssueTracker)
|
f.Patch("/issue-tracker", reqRepoWriter(), bind(api.EditIssueTrackerOption{}), repo.IssueTracker)
|
||||||
m.Patch("/wiki", reqRepoWriter(), bind(api.EditWikiOption{}), repo.Wiki)
|
f.Patch("/wiki", reqRepoWriter(), bind(api.EditWikiOption{}), repo.Wiki)
|
||||||
m.Post("/mirror-sync", reqRepoWriter(), repo.MirrorSync)
|
f.Post("/mirror-sync", reqRepoWriter(), repo.MirrorSync)
|
||||||
m.Get("/editorconfig/:filename", context.RepoRef(), repo.GetEditorconfig)
|
f.Get("/editorconfig/:filename", context.RepoRef(), repo.GetEditorconfig)
|
||||||
}, repoAssignment())
|
}, repoAssignment())
|
||||||
}, reqToken())
|
}, reqToken())
|
||||||
|
|
||||||
m.Get("/issues", reqToken(), repo.ListUserIssues)
|
f.Get("/issues", reqToken(), repo.ListUserIssues)
|
||||||
|
|
||||||
// Organizations
|
// Organizations
|
||||||
m.Combo("/user/orgs", reqToken()).
|
f.Combo("/user/orgs", reqToken()).
|
||||||
Get(org.ListMyOrgs).
|
Get(org.ListMyOrgs).
|
||||||
Post(bind(api.CreateOrgOption{}), org.CreateMyOrg)
|
Post(bind(api.CreateOrgOption{}), org.CreateMyOrg)
|
||||||
|
|
||||||
m.Get("/users/:username/orgs", org.ListUserOrgs)
|
f.Get("/users/:username/orgs", org.ListUserOrgs)
|
||||||
m.Group("/orgs/:orgname", func() {
|
f.Group("/orgs/:orgname", func() {
|
||||||
m.Combo("").
|
f.Combo("").
|
||||||
Get(org.Get).
|
Get(org.Get).
|
||||||
Patch(bind(api.EditOrgOption{}), org.Edit)
|
Patch(bind(api.EditOrgOption{}), org.Edit)
|
||||||
m.Get("/teams", org.ListTeams)
|
f.Get("/teams", org.ListTeams)
|
||||||
}, orgAssignment(true))
|
}, orgAssignment(true))
|
||||||
|
|
||||||
m.Group("/admin", func() {
|
f.Group("/admin", func() {
|
||||||
m.Group("/users", func() {
|
f.Group("/users", func() {
|
||||||
m.Post("", bind(api.CreateUserOption{}), admin.CreateUser)
|
f.Post("", bind(api.CreateUserOption{}), admin.CreateUser)
|
||||||
|
|
||||||
m.Group("/:username", func() {
|
f.Group("/:username", func() {
|
||||||
m.Combo("").
|
f.Combo("").
|
||||||
Patch(bind(api.EditUserOption{}), admin.EditUser).
|
Patch(bind(api.EditUserOption{}), admin.EditUser).
|
||||||
Delete(admin.DeleteUser)
|
Delete(admin.DeleteUser)
|
||||||
m.Post("/keys", bind(api.CreateKeyOption{}), admin.CreatePublicKey)
|
f.Post("/keys", bind(api.CreateKeyOption{}), admin.CreatePublicKey)
|
||||||
m.Post("/orgs", bind(api.CreateOrgOption{}), admin.CreateOrg)
|
f.Post("/orgs", bind(api.CreateOrgOption{}), admin.CreateOrg)
|
||||||
m.Post("/repos", bind(api.CreateRepoOption{}), admin.CreateRepo)
|
f.Post("/repos", bind(api.CreateRepoOption{}), admin.CreateRepo)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
m.Group("/orgs/:orgname", func() {
|
f.Group("/orgs/:orgname", func() {
|
||||||
m.Group("/teams", func() {
|
f.Group("/teams", func() {
|
||||||
m.Post("", orgAssignment(true), bind(api.CreateTeamOption{}), admin.CreateTeam)
|
f.Post("", orgAssignment(true), bind(api.CreateTeamOption{}), admin.CreateTeam)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
m.Group("/teams", func() {
|
f.Group("/teams", func() {
|
||||||
m.Group("/:teamid", func() {
|
f.Group("/:teamid", func() {
|
||||||
m.Get("/members", admin.ListTeamMembers)
|
f.Get("/members", admin.ListTeamMembers)
|
||||||
m.Combo("/members/:username").
|
f.Combo("/members/:username").
|
||||||
Put(admin.AddTeamMember).
|
Put(admin.AddTeamMember).
|
||||||
Delete(admin.RemoveTeamMember)
|
Delete(admin.RemoveTeamMember)
|
||||||
m.Combo("/repos/:reponame").
|
f.Combo("/repos/:reponame").
|
||||||
Put(admin.AddTeamRepository).
|
Put(admin.AddTeamRepository).
|
||||||
Delete(admin.RemoveTeamRepository)
|
Delete(admin.RemoveTeamRepository)
|
||||||
}, orgAssignment(false, true))
|
}, orgAssignment(false, true))
|
||||||
})
|
})
|
||||||
}, reqAdmin())
|
}, reqAdmin())
|
||||||
|
|
||||||
m.Any("/*", func(c *context.Context) {
|
f.Any("/*", func(c *context.Context) {
|
||||||
c.NotFound()
|
c.NotFound()
|
||||||
})
|
})
|
||||||
}, context.APIContexter())
|
}, context.APIContexter())
|
||||||
|
|||||||
Reference in New Issue
Block a user