Add bot blocker functionality and update security middleware

- Introduced a bot blocker initialized with a user agent blocklist.
- Updated the security middleware to utilize the new bot blocker in both main and test files.
- Enhanced error handling for API requests to return a proper 404 response when content is not found.
This commit is contained in:
2025-12-27 03:15:31 -06:00
parent 9a3afd61ed
commit f08e148b2f
2 changed files with 13 additions and 2 deletions

View File

@@ -46,11 +46,12 @@ func TestMainHandlers(t *testing.T) {
giteaServer = mockGitea.URL
statsService := stats.NewService("test-hashes.json")
botBlocker := security.NewBotBlocker("")
initialSoftware := config.LoadSoftware(configPath, giteaServer, "")
apiServer := api.NewServer("", initialSoftware, statsService)
r := chi.NewRouter()
r.Use(security.SecurityMiddleware(statsService))
r.Use(security.SecurityMiddleware(statsService, botBlocker))
r.Get("/api/software", apiServer.APISoftwareHandler)
r.Get("/api/stats", statsService.APIStatsHandler)
r.Get("/api/download", apiServer.DownloadProxyHandler)