Files
njump/agentblock.go
2024-09-26 07:54:55 +02:00

21 lines
445 B
Go

package main
import (
"net/http"
"strings"
)
func agentBlock(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
userAgent := r.UserAgent()
if strings.Contains(userAgent, "Amazonbot") {
// Drop the request by returning a 403 Forbidden response
http.Error(w, "Forbidden", http.StatusForbidden)
return
}
// Call the next handler in the chain
next.ServeHTTP(w, r)
})
}