(db *explorer.Database)
| 12 | ) |
| 13 | |
| 14 | func 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 | } |
no test coverage detected