package router import ( "bookhoard/internal/docs" ) func registerDocumentationRoutes(cfg *Config) { docsHandler := docs.NewHTTPHandler("docs") // Docs render for anonymous AND signed-in visitors (it's the pre-login // surface for setup/troubleshooting), so the HTML routes use the optional // auth middleware: handlers get a populated user when a valid token is // present, nil otherwise. The JSON/partial endpoints are public. docsAuth := createOptionalAuthMiddleware(cfg) cfg.Echo.GET("/docs", docsHandler.DocsHome, docsAuth) cfg.Echo.GET("/docs/*", docsHandler.ShowDocumentation, docsAuth) // Server-rendered search results partial (swapped in by web/src/docs.ts). cfg.Echo.GET("/docs/search/partial", docsHandler.SearchPartial) cfg.Echo.GET("/docs/api/search", docsHandler.Search) cfg.Echo.GET("/docs/search-index.json", docsHandler.ServeSearchIndex) }