MCPcopy Index your code
hub / github.com/apache/devlake / PostProject

Function PostProject

backend/server/api/project/project.go:116–135  ·  view source on GitHub ↗

@Summary Create a new project @Description Create a new project @Tags framework/projects @Accept application/json @Param project body models.ApiInputProject true "json" @Success 200 {object} models.ApiOutputProject @Failure 400 {string} errcode.Error "Bad Request" @Failure 500 {string} errcode.Er

(c *gin.Context)

Source from the content-addressed store, hash-verified

114// @Failure 500 {string} errcode.Error "Internal Error"
115// @Router /projects [post]
116func PostProject(c *gin.Context) {
117 projectInput := &models.ApiInputProject{}
118 err := c.ShouldBind(projectInput)
119 if err != nil {
120 shared.ApiOutputError(c, errors.BadInput.Wrap(err, shared.BadRequestBody))
121 return
122 }
123 if len(projectInput.BaseProject.Name) > 100 {
124 shared.ApiOutputError(c, errors.BadInput.New("Project name is too long."))
125 return
126 }
127
128 projectOutput, err := services.CreateProject(projectInput)
129 if err != nil {
130 shared.ApiOutputError(c, errors.Default.Wrap(err, "error creating project"))
131 return
132 }
133
134 shared.ApiOutputSuccess(c, projectOutput, http.StatusCreated)
135}
136
137// @Summary Patch a project
138// @Description Patch a project

Callers

nothing calls this directly

Calls 3

WrapMethod · 0.80
CreateProjectMethod · 0.80
NewMethod · 0.65

Tested by

no test coverage detected