Parcourir la source

begin drafting new api endpoint

Ivan Galakhov il y a 5 ans
Parent
commit
bed7af87a8
2 fichiers modifiés avec 26 ajouts et 0 suppressions
  1. 12 0
      server/api/git_repo_handler.go
  2. 14 0
      server/router/router.go

+ 12 - 0
server/api/git_repo_handler.go

@@ -209,6 +209,18 @@ func (app *App) HandleGetBranches(w http.ResponseWriter, r *http.Request) {
 	json.NewEncoder(w).Encode(res)
 }
 
+// HandleDetectBuildpack attempts to figure which buildpack will be auto used based on directory contents
+func (app *App) HandleDetectBuildpack(w http.ResponseWriter, r *http.Request) {
+	tok, err := app.githubTokenFromRequest(r)
+
+	if err != nil {
+		app.handleErrorInternal(err, w)
+		return
+	}
+
+	json.NewEncoder(w).Encode(tok)
+}
+
 // HandleGetBranchContents retrieves the contents of a specific branch and subdirectory
 func (app *App) HandleGetBranchContents(w http.ResponseWriter, r *http.Request) {
 	tok, err := app.githubTokenFromRequest(r)

+ 14 - 0
server/router/router.go

@@ -1028,6 +1028,20 @@ func New(a *api.App) *chi.Mux {
 				),
 			)
 
+			r.Method(
+				"GET",
+				"/projects/{project_id}/gitrepos/{git_repo_id}/repos/{kind}/{owner}/{name}/{branch}/buildpack/detect",
+				auth.DoesUserHaveProjectAccess(
+					auth.DoesUserHaveGitRepoAccess(
+						requestlog.NewHandler(a.HandleDetectBuildpack, l),
+						mw.URLParam,
+						mw.URLParam,
+					),
+					mw.URLParam,
+					mw.ReadAccess,
+				),
+			)
+
 			r.Method(
 				"GET",
 				"/projects/{project_id}/gitrepos/{git_repo_id}/repos/{kind}/{owner}/{name}/{branch}/contents",