-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhtml.go
38 lines (31 loc) · 881 Bytes
/
html.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
package gotenberg
type ConvertHTMLRequest struct {
index Document
assets []Document
*chromiumRequest
}
func NewConvertHTMLRequest(index Document) *ConvertHTMLRequest {
return &ConvertHTMLRequest{index: index, assets: []Document{}, chromiumRequest: newChromiumRequest()}
}
func (req *ConvertHTMLRequest) postURL() string {
return "/forms/chromium/convert/html"
}
// Assets sets assets form files.
func (req *ConvertHTMLRequest) Assets(assets ...Document) {
req.assets = assets
}
func (req *ConvertHTMLRequest) formFiles() map[string]Document {
files := make(map[string]Document)
files["index.html"] = req.index
if req.header != nil {
files["header.html"] = req.header
}
if req.footer != nil {
files["footer.html"] = req.footer
}
for _, asset := range req.assets {
files[asset.Filename()] = asset
}
return files
}
var _ Request = new(ConvertHTMLRequest)