MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / Search

Method Search

api/api.go:188–209  ·  view source on GitHub ↗

Search performs a search query on a specified collection. It binds the incoming JSON request to a SearchCollectionParams object, executes the search query, and responds with the search results. Parameters: - c: The Gin context containing the request and response. Responses: - 400 Bad Request: If t

(c *gin.Context)

Source from the content-addressed store, hash-verified

186// - 400 Bad Request: If there's an error in binding JSON or performing the search.
187// - 201 Created: If the search query is successfully executed and results are returned.
188func (a Api) Search(c *gin.Context) {
189 collection, passed := c.Params.Get("collection")
190 if !passed {
191 c.JSON(http.StatusBadRequest, gin.H{"error": "collection is required. pass id in the route /:collection"})
192 return
193 }
194
195 var query api.SearchCollectionParams
196 err := c.BindJSON(&query)
197 if err != nil {
198 c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
199 return
200 }
201
202 resp, err := a.ledgerforge.Search(collection, &query)
203 if err != nil {
204 c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
205 return
206 }
207
208 c.JSON(http.StatusCreated, resp)
209}
210
211// MultiSearch performs a multi-search query.
212// It binds the incoming JSON request to a MultiSearchParameter object,

Callers

nothing calls this directly

Calls 2

GetMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected