| 31 | } |
| 32 | |
| 33 | func notFoundHandler(c echo.Context) error { |
| 34 | // Check if the request accepts JSON |
| 35 | contentType := c.Request().Header.Get("Content-Type") |
| 36 | accept := c.Request().Header.Get("Accept") |
| 37 | if strings.Contains(contentType, "application/json") || !strings.Contains(accept, "text/html") { |
| 38 | // The client expects a JSON response |
| 39 | return c.JSON(http.StatusNotFound, schema.ErrorResponse{ |
| 40 | Error: &schema.APIError{Message: "Resource not found", Code: http.StatusNotFound}, |
| 41 | }) |
| 42 | } else { |
| 43 | // The client expects an HTML response |
| 44 | return c.Render(http.StatusNotFound, "views/404", map[string]any{ |
| 45 | "BaseURL": middleware.BaseURL(c), |
| 46 | }) |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | func renderEngine() *TemplateRenderer { |
| 51 | // Parse all templates from embedded filesystem |