Head API added. Opt renamed to Options. Tests updated. More documentation added.

This commit is contained in:
Musab Gültekin
2019-06-08 20:13:16 +03:00
parent 95d97436bf
commit b90908066b
4 changed files with 31 additions and 16 deletions

View File

@ -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)