ApplyPattern handles the POST /patterns/:name/apply route @Summary Apply pattern with variables @Description Apply a pattern with variable substitution @Tags patterns @Accept json @Produce json @Param name path string true "Pattern name" @Param request body PatternApplyRequest true "Pattern applicat
(c *gin.Context)
| 74 | // @Security ApiKeyAuth |
| 75 | // @Router /patterns/{name}/apply [post] |
| 76 | func (h *PatternsHandler) ApplyPattern(c *gin.Context) { |
| 77 | name := c.Param("name") |
| 78 | |
| 79 | var request PatternApplyRequest |
| 80 | if err := c.ShouldBindJSON(&request); err != nil { |
| 81 | c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) |
| 82 | return |
| 83 | } |
| 84 | |
| 85 | // Merge query parameters with request body variables (body takes precedence) |
| 86 | variables := make(map[string]string) |
| 87 | for key, values := range c.Request.URL.Query() { |
| 88 | if len(values) > 0 { |
| 89 | variables[key] = values[0] |
| 90 | } |
| 91 | } |
| 92 | maps.Copy(variables, request.Variables) |
| 93 | |
| 94 | pattern, err := h.patterns.GetApplyVariables(name, variables, request.Input) |
| 95 | if err != nil { |
| 96 | c.JSON(http.StatusInternalServerError, err.Error()) |
| 97 | return |
| 98 | } |
| 99 | c.JSON(http.StatusOK, pattern) |
| 100 | } |
nothing calls this directly
no test coverage detected