summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/api.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api/v1/api.go')
-rw-r--r--routers/api/v1/api.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index 506a615624..b920a23593 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -167,6 +167,13 @@ func mustEnableIssues(ctx *context.APIContext) {
}
}
+func mustAllowPulls(ctx *context.Context) {
+ if !ctx.Repo.Repository.AllowsPulls() {
+ ctx.Status(404)
+ return
+ }
+}
+
// RegisterRoutes registers all v1 APIs routes to web application.
// FIXME: custom form error response
func RegisterRoutes(m *macaron.Macaron) {
@@ -305,6 +312,14 @@ func RegisterRoutes(m *macaron.Macaron) {
Delete(reqRepoWriter(), repo.DeleteMilestone)
})
m.Get("/editorconfig/:filename", context.RepoRef(), repo.GetEditorconfig)
+ m.Group("/pulls", func() {
+ m.Combo("").Get(bind(api.ListPullRequestsOptions{}), repo.ListPullRequests).Post(reqRepoWriter(), bind(api.CreatePullRequestOption{}), repo.CreatePullRequest)
+ m.Group("/:index", func() {
+ m.Combo("").Get(repo.GetPullRequest).Patch(reqRepoWriter(), bind(api.EditPullRequestOption{}), repo.EditPullRequest)
+ m.Combo("/merge").Get(repo.IsPullRequestMerged).Post(reqRepoWriter(), repo.MergePullRequest)
+ })
+
+ }, mustAllowPulls, context.ReferencesGitRepo())
}, repoAssignment())
}, reqToken())