MCPcopy Create free account
hub / github.com/dionysia-dev/dionysia / CreateInput

Method CreateInput

internal/api/controller.go:36–67  ·  view source on GitHub ↗

@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)

Source from the content-addressed store, hash-verified

34// @Failure 500 {object} api.ErrorResponse "Internal server error"
35// @Router /inputs [post]
36func (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

Callers

nothing calls this directly

Calls 4

ToInputMethod · 0.95
HandleValidationErrorFunction · 0.85
FromInputFunction · 0.85
CreateInputMethod · 0.65

Tested by

no test coverage detected