forked from thecodingmachine/gotenberg-go-client
-
Notifications
You must be signed in to change notification settings - Fork 3
/
url.go
46 lines (35 loc) · 992 Bytes
/
url.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package gotenberg
import "github.com/starwalkn/gotenberg-go-client/v8/document"
const (
endpointURLConvert = "/forms/chromium/convert/url"
endpointURLScreenshot = "/forms/chromium/screenshot/url"
)
// URLRequest facilitates remote URL conversion with the Gotenberg API.
type URLRequest struct {
*chromiumRequest
}
func NewURLRequest(url string) *URLRequest {
req := &URLRequest{newChromiumRequest()}
req.fields[fieldURL] = url
return req
}
func (req *URLRequest) endpoint() string {
return endpointURLConvert
}
func (req *URLRequest) screenshotEndpoint() string {
return endpointURLScreenshot
}
func (req *URLRequest) formDocuments() map[string]document.Document {
files := make(map[string]document.Document)
if req.header != nil {
files["header.html"] = req.header
}
if req.footer != nil {
files["footer.html"] = req.footer
}
return files
}
// Compile-time checks to ensure type implements desired interfaces.
var (
_ = multipartRequester(new(URLRequest))
)