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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user