Extractors removed as they introduce complexity to scraper. Both in learning and developing.
		
			
				
	
	
		
			20 lines
		
	
	
		
			460 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			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
 | 
						|
	}
 | 
						|
}
 |