@Summary Create an input @Description Create an input ready to be ingested @Accept json @Produce json @Param input body api.InputData true "Input data" @Success 201 {object} api.SuccessResponse @Failure 400 {object} api.ErrorResponse "Invalid input data" @Failure 500 {object} api.ErrorResponse "Inte
(ctx *gin.Context)
| 34 | // @Failure 500 {object} api.ErrorResponse "Internal server error" |
| 35 | // @Router /inputs [post] |
| 36 | func (c *InputController) CreateInput(ctx *gin.Context) { |
| 37 | var inputData InputData |
| 38 | if err := ctx.BindJSON(&inputData); err != nil { |
| 39 | statusCode, response := HandleValidationError(err) |
| 40 | if statusCode == 0 && response == nil { |
| 41 | ctx.JSON(http.StatusInternalServerError, ErrorResponse{ |
| 42 | Error: Error{Message: "InternalServerError: handle validation failed"}, |
| 43 | }) |
| 44 | |
| 45 | return |
| 46 | } |
| 47 | |
| 48 | ctx.JSON(int(statusCode), response) |
| 49 | |
| 50 | return |
| 51 | } |
| 52 | |
| 53 | input, err := c.inputHandler.CreateInput(ctx, inputData.ToInput()) |
| 54 | if err != nil { |
| 55 | ctx.JSON(http.StatusInternalServerError, ErrorResponse{ |
| 56 | Error: Error{Message: "InternalServerError: failed creating input"}, |
| 57 | }) |
| 58 | |
| 59 | return |
| 60 | } |
| 61 | |
| 62 | responseData := FromInput(input) |
| 63 | ctx.JSON(http.StatusCreated, SuccessResponse{ |
| 64 | Message: "Input created successfully", |
| 65 | Data: responseData, |
| 66 | }) |
| 67 | } |
| 68 | |
| 69 | // @Summary Get input |
| 70 | // @Description Get input information by ID |
nothing calls this directly
no test coverage detected