From 415e2ff2657d2f5cac5c81548e5f3887a6bf1b40 Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Wed, 24 Nov 2021 16:20:10 +0100 Subject: [PATCH] feat(chromium): add 'extraLinkTags' and 'extraScriptTags' form fields, add auto-detection of files for URL endpoint, disable some functionalities if JavaScript is disabled --- pkg/modules/chromium/chromium.go | 157 +++++++++++- pkg/modules/chromium/chromium_test.go | 23 ++ pkg/modules/chromium/routes.go | 196 ++++++++++++++- pkg/modules/chromium/routes_test.go | 223 +++++++++++++++++- .../testdata/chromium/html/sample11/font.woff | Bin 0 -> 12644 bytes .../chromium/html/sample11/index.html | 12 + .../testdata/chromium/html/sample11/script.js | 2 + .../testdata/chromium/html/sample11/style.css | 14 ++ 8 files changed, 613 insertions(+), 14 deletions(-) create mode 100644 test/testdata/chromium/html/sample11/font.woff create mode 100644 test/testdata/chromium/html/sample11/index.html create mode 100644 test/testdata/chromium/html/sample11/script.js create mode 100644 test/testdata/chromium/html/sample11/style.css diff --git a/pkg/modules/chromium/chromium.go b/pkg/modules/chromium/chromium.go index e5ad6f31..97d666fe 100644 --- a/pkg/modules/chromium/chromium.go +++ b/pkg/modules/chromium/chromium.go @@ -21,6 +21,7 @@ import ( "github.com/gotenberg/gotenberg/v7/pkg/modules/api" flag "github.com/spf13/pflag" "go.uber.org/zap" + "golang.org/x/sync/errgroup" ) func init() { @@ -75,10 +76,25 @@ type Chromium struct { disableRoutes bool } +// LinkTag represents an HTML element. +type LinkTag struct { + // Href is the "href" attribute of the HTML element. + // Required. + Href string `json:"href"` +} + +// ScriptTag represents an HTML