diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-11-13 12:57:00 -0500 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-11-13 12:57:00 -0500 |
commit | 9dc3c93a6a1f0d604aa5e4408a4c43c29b963b0c (patch) | |
tree | 0d2113af522fa36d2c73760c3aace4088ee3ae78 /cmd/web.go | |
parent | 9e2284048372864a7dbc5e192877ebdca04abcab (diff) | |
download | gitea-9dc3c93a6a1f0d604aa5e4408a4c43c29b963b0c.tar.gz gitea-9dc3c93a6a1f0d604aa5e4408a4c43c29b963b0c.zip |
#12, add/edit hook
Diffstat (limited to 'cmd/web.go')
-rw-r--r-- | cmd/web.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/cmd/web.go b/cmd/web.go index 74cfb75a03..acc5cc8f4f 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -145,6 +145,7 @@ func runWeb(*cli.Context) { ignSignInAndCsrf := middleware.Toggle(&middleware.ToggleOptions{DisableCsrf: true}) reqSignOut := middleware.Toggle(&middleware.ToggleOptions{SignOutRequire: true}) + bind := binding.Bind bindIgnErr := binding.BindIgnErr // Routers. @@ -158,6 +159,7 @@ func runWeb(*cli.Context) { }, reqSignIn) // API. + // FIXME: custom form error response. m.Group("/api", func() { m.Group("/v1", func() { // Miscellaneous. @@ -170,14 +172,15 @@ func runWeb(*cli.Context) { }) // Repositories. - m.Get("/user/repos", v1.ListMyRepos) + m.Get("/user/repos", middleware.ApiReqToken(), v1.ListMyRepos) m.Group("/repos", func() { m.Get("/search", v1.SearchRepos) m.Post("/migrate", bindIgnErr(auth.MigrateRepoForm{}), v1.Migrate) m.Group("/:username/:reponame", func() { - m.Combo("/hooks").Get(v1.ListRepoHooks) - }, middleware.ApiRepoAssignment()) + m.Combo("/hooks").Get(v1.ListRepoHooks).Post(bind(v1.CreateRepoHookForm{}), v1.CreateRepoHook) + m.Patch("/hooks/:id:int", bind(v1.EditRepoHookForm{}), v1.EditRepoHook) + }, middleware.ApiRepoAssignment(), middleware.ApiReqToken()) }) m.Any("/*", func(ctx *middleware.Context) { |