Extractors refactored to support pass by value. Documentation added for request and response.

This commit is contained in:
Musab Gültekin
2019-07-04 02:13:29 +03:00
parent 71683ec6de
commit da03567fae
9 changed files with 51 additions and 28 deletions

View File

@ -98,7 +98,6 @@ func (c *Client) DoRequestClient(req *Request, maxBodySize int64, charsetDetectD
response := Response{
Response: resp,
Body: body,
Meta: req.Meta,
Request: req,
}
@ -161,7 +160,6 @@ func (c *Client) DoRequestChrome(req *Request) (*Response, error) {
Header: ConvertMapToHeader(res.Headers),
},
Body: []byte(body),
Meta: req.Meta,
Request: req,
}

View File

@ -8,11 +8,24 @@ import (
// Request is a small wrapper around *http.Request that contains Metadata and Rendering option
type Request struct {
*http.Request
Meta map[string]interface{}
// Meta contains arbitrary data.
// Use this Meta map to store contextual data between your requests
Meta map[string]interface{}
// If true, requests will be synchronized
Synchronized bool
Rendered bool
Cancelled bool
Encoding string
// If true request will be opened in Chrome and
// fully rendered HTML DOM response will returned as response
Rendered bool
// Optional response body encoding. Leave empty for automatic detection.
// If you're having issues with auto detection, set this.
Encoding string
// Set this true to cancel requests. Should be used on middlewares.
Cancelled bool
}
// Cancel request

View File

@ -11,9 +11,13 @@ import (
// Contains parsed response data and Geziyor functions.
type Response struct {
*http.Response
Body []byte
// Response body
Body []byte
// Goquery Document object. If response IsHTML, its non-nil.
HTMLDoc *goquery.Document
Meta map[string]interface{}
Request *Request
}