@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)
| 114 | // @Failure 500 {string} errcode.Error "Internal Error" |
| 115 | // @Router /projects [post] |
| 116 | func 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 |
nothing calls this directly
no test coverage detected