MCPcopy
hub / github.com/mudler/LocalAI / Explorer

Function Explorer

core/http/explorer.go:14–50  ·  view source on GitHub ↗
(db *explorer.Database)

Source from the content-addressed store, hash-verified

12)
13
14func Explorer(db *explorer.Database) *echo.Echo {
15 e := echo.New()
16
17 // Set renderer
18 e.Renderer = renderEngine()
19
20 // Hide banner
21 e.HideBanner = true
22
23 e.Pre(middleware.StripPathPrefix())
24 routes.RegisterExplorerRoutes(e, db)
25
26 // Favicon handler
27 e.GET("/favicon.svg", func(c echo.Context) error {
28 data, err := embedDirStatic.ReadFile("static/favicon.svg")
29 if err != nil {
30 return c.NoContent(http.StatusNotFound)
31 }
32 c.Response().Header().Set("Content-Type", "image/svg+xml")
33 return c.Blob(http.StatusOK, "image/svg+xml", data)
34 })
35
36 // Static files - use fs.Sub to create a filesystem rooted at "static"
37 staticFS, err := fs.Sub(embedDirStatic, "static")
38 if err != nil {
39 // Log error but continue - static files might not work
40 xlog.Error("failed to create static filesystem", "error", err)
41 } else {
42 e.StaticFS("/static", staticFS)
43 }
44
45 // Define a custom 404 handler
46 // Note: keep this at the bottom!
47 e.GET("/*", notFoundHandler)
48
49 return e
50}

Callers 1

RunMethod · 0.92

Calls 6

StripPathPrefixFunction · 0.92
RegisterExplorerRoutesFunction · 0.92
renderEngineFunction · 0.85
HeaderMethod · 0.80
SetMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected