geziyor/middleware/allowed_domains.go
Musab Gültekin 2cab68d2ce Middlewares refactored to multiple files in middleware package.
Extractors removed as they introduce complexity to scraper. Both in learning and developing.
2019-07-04 21:04:29 +03:00

20 lines
460 B
Go

package middleware
import (
"github.com/geziyor/geziyor/client"
"github.com/geziyor/geziyor/internal"
)
// AllowedDomains checks for request host if it exists in AllowedDomains
type AllowedDomains struct {
AllowedDomains []string
}
func (a *AllowedDomains) ProcessRequest(r *client.Request) {
if len(a.AllowedDomains) != 0 && !internal.Contains(a.AllowedDomains, r.Host) {
//log.Printf("Domain not allowed: %s\n", req.Host)
r.Cancel()
return
}
}