Head API added. Opt renamed to Options. Tests updated. More documentation added.
This commit is contained in:
18
geziyor.go
18
geziyor.go
@ -18,13 +18,13 @@ import (
|
||||
type Geziyor struct {
|
||||
client *http.Client
|
||||
wg sync.WaitGroup
|
||||
opt Opt
|
||||
opt Options
|
||||
|
||||
visitedURLS []string
|
||||
}
|
||||
|
||||
// Opt is custom options type for Geziyor
|
||||
type Opt struct {
|
||||
// Options is custom options type for Geziyor
|
||||
type Options struct {
|
||||
AllowedDomains []string
|
||||
StartURLs []string
|
||||
ParseFunc func(response *Response)
|
||||
@ -37,7 +37,7 @@ func init() {
|
||||
|
||||
// NewGeziyor creates new Geziyor with default values.
|
||||
// If options provided, options
|
||||
func NewGeziyor(opt Opt) *Geziyor {
|
||||
func NewGeziyor(opt Options) *Geziyor {
|
||||
geziyor := &Geziyor{
|
||||
client: &http.Client{
|
||||
Timeout: time.Second * 10,
|
||||
@ -72,6 +72,16 @@ func (g *Geziyor) Get(url string) {
|
||||
g.Do(req)
|
||||
}
|
||||
|
||||
// Head issues a HEAD to the specified URL
|
||||
func (g *Geziyor) Head(url string) {
|
||||
req, err := http.NewRequest("HEAD", url, nil)
|
||||
if err != nil {
|
||||
log.Printf("Request creating error %v\n", err)
|
||||
return
|
||||
}
|
||||
g.Do(req)
|
||||
}
|
||||
|
||||
// Do sends an HTTP request
|
||||
func (g *Geziyor) Do(req *http.Request) {
|
||||
g.wg.Add(1)
|
||||
|
Reference in New Issue
Block a user