MCPcopy Create free account
hub / github.com/bricks-cloud/BricksLLM / getDeleteRouteHandler

Function getDeleteRouteHandler

internal/server/web/admin/route.go:172–232  ·  view source on GitHub ↗
(m RouteManager, prod bool)

Source from the content-addressed store, hash-verified

170}
171
172func getDeleteRouteHandler(m RouteManager, prod bool) gin.HandlerFunc {
173 return func(c *gin.Context) {
174 log := util.GetLogFromCtx(c)
175 telemetry.Incr("bricksllm.admin.get_delete_route_handler.requests", nil, 1)
176
177 start := time.Now()
178 defer func() {
179 dur := time.Since(start)
180 telemetry.Timing("bricksllm.admin.get_delete_route_handler.latency", dur, nil, 1)
181 }()
182
183 path := "/api/routes/:id"
184 if c == nil || c.Request == nil {
185 c.JSON(http.StatusInternalServerError, &ErrorResponse{
186 Type: "/errors/empty-context",
187 Title: "context is empty error",
188 Status: http.StatusInternalServerError,
189 Detail: "gin context is empty",
190 Instance: path,
191 })
192 return
193 }
194
195 err := m.DeleteRoute(c.Param("id"))
196 if err != nil {
197 errType := "internal"
198 defer func() {
199 telemetry.Incr("bricksllm.admin.get_delete_route_handler.delete_route_err", []string{
200 "error_type:" + errType,
201 }, 1)
202 }()
203
204 if _, ok := err.(notFoundError); ok {
205 errType = "not_found"
206
207 logError(log, "route not found", prod, err)
208 c.JSON(http.StatusNotFound, &ErrorResponse{
209 Type: "/errors/route-not-found",
210 Title: "route not found error",
211 Status: http.StatusNotFound,
212 Detail: err.Error(),
213 Instance: path,
214 })
215 return
216 }
217
218 logError(log, "error when deleting a route", prod, err)
219 c.JSON(http.StatusInternalServerError, &ErrorResponse{
220 Type: "/errors/route-manager",
221 Title: "deleting a route error",
222 Status: http.StatusInternalServerError,
223 Detail: err.Error(),
224 Instance: path,
225 })
226 return
227 }
228
229 telemetry.Incr("bricksllm.admin.get_delete_route_handler.success", nil, 1)

Callers 1

NewAdminServerFunction · 0.85

Calls 6

GetLogFromCtxFunction · 0.92
IncrFunction · 0.92
TimingFunction · 0.92
logErrorFunction · 0.70
DeleteRouteMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected