(m RouteManager, prod bool)
| 232 | } |
| 233 | |
| 234 | func getGetRoutesHandler(m RouteManager, prod bool) gin.HandlerFunc { |
| 235 | return func(c *gin.Context) { |
| 236 | log := util.GetLogFromCtx(c) |
| 237 | telemetry.Incr("bricksllm.admin.get_get_routes_handler.requests", nil, 1) |
| 238 | |
| 239 | start := time.Now() |
| 240 | defer func() { |
| 241 | dur := time.Since(start) |
| 242 | telemetry.Timing("bricksllm.admin.get_get_routes_handler.latency", dur, nil, 1) |
| 243 | }() |
| 244 | |
| 245 | path := "/api/routes" |
| 246 | if c == nil || c.Request == nil { |
| 247 | c.JSON(http.StatusInternalServerError, &ErrorResponse{ |
| 248 | Type: "/errors/empty-context", |
| 249 | Title: "context is empty error", |
| 250 | Status: http.StatusInternalServerError, |
| 251 | Detail: "gin context is empty", |
| 252 | Instance: path, |
| 253 | }) |
| 254 | return |
| 255 | } |
| 256 | |
| 257 | rs, err := m.GetRoutes() |
| 258 | if err != nil { |
| 259 | errType := "internal" |
| 260 | defer func() { |
| 261 | telemetry.Incr("bricksllm.admin.get_get_routes_handler.get_custom_providers_err", []string{ |
| 262 | "error_type:" + errType, |
| 263 | }, 1) |
| 264 | }() |
| 265 | |
| 266 | logError(log, "error when getting a route", prod, err) |
| 267 | c.JSON(http.StatusInternalServerError, &ErrorResponse{ |
| 268 | Type: "/errors/route-manager", |
| 269 | Title: "getting a route error", |
| 270 | Status: http.StatusInternalServerError, |
| 271 | Detail: err.Error(), |
| 272 | Instance: path, |
| 273 | }) |
| 274 | return |
| 275 | } |
| 276 | |
| 277 | telemetry.Incr("bricksllm.admin.get_get_routes_handler.success", nil, 1) |
| 278 | c.JSON(http.StatusOK, rs) |
| 279 | } |
| 280 | } |
no test coverage detected