mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-17 12:42:16 +01:00
chore: reorganize useAgent form field
This commit is contained in:
@@ -61,10 +61,6 @@ type Chromium struct {
|
|||||||
|
|
||||||
// Options are the available options for converting HTML document to PDF.
|
// Options are the available options for converting HTML document to PDF.
|
||||||
type Options struct {
|
type Options struct {
|
||||||
// UserAgent overrides the default User-Agent header.
|
|
||||||
// Optional.
|
|
||||||
UserAgent string
|
|
||||||
|
|
||||||
// WaitDelay is the duration to wait when loading an HTML document before
|
// WaitDelay is the duration to wait when loading an HTML document before
|
||||||
// converting it to PDF.
|
// converting it to PDF.
|
||||||
// Optional.
|
// Optional.
|
||||||
@@ -75,6 +71,10 @@ type Options struct {
|
|||||||
// Optional.
|
// Optional.
|
||||||
WaitWindowStatus string
|
WaitWindowStatus string
|
||||||
|
|
||||||
|
// UserAgent overrides the default User-Agent header.
|
||||||
|
// Optional.
|
||||||
|
UserAgent string
|
||||||
|
|
||||||
// ExtraHTTPHeaders are the HTTP headers to send by Chromium while loading
|
// ExtraHTTPHeaders are the HTTP headers to send by Chromium while loading
|
||||||
// the HTML document.
|
// the HTML document.
|
||||||
// Optional.
|
// Optional.
|
||||||
@@ -147,9 +147,9 @@ type Options struct {
|
|||||||
// DefaultOptions returns the default values for Options.
|
// DefaultOptions returns the default values for Options.
|
||||||
func DefaultOptions() Options {
|
func DefaultOptions() Options {
|
||||||
return Options{
|
return Options{
|
||||||
UserAgent: "",
|
|
||||||
WaitDelay: 0,
|
WaitDelay: 0,
|
||||||
WaitWindowStatus: "",
|
WaitWindowStatus: "",
|
||||||
|
UserAgent: "",
|
||||||
ExtraHTTPHeaders: nil,
|
ExtraHTTPHeaders: nil,
|
||||||
Landscape: false,
|
Landscape: false,
|
||||||
PrintBackground: false,
|
PrintBackground: false,
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ func FormDataChromiumPDFOptions(ctx *api.Context) (*api.FormData, Options) {
|
|||||||
defaultOptions := DefaultOptions()
|
defaultOptions := DefaultOptions()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
userAgent string
|
|
||||||
waitDelay time.Duration
|
waitDelay time.Duration
|
||||||
waitWindowStatus string
|
waitWindowStatus string
|
||||||
|
userAgent string
|
||||||
extraHTTPHeaders map[string]string
|
extraHTTPHeaders map[string]string
|
||||||
landscape, printBackground bool
|
landscape, printBackground bool
|
||||||
scale, paperWidth, paperHeight float64
|
scale, paperWidth, paperHeight float64
|
||||||
@@ -39,9 +39,9 @@ func FormDataChromiumPDFOptions(ctx *api.Context) (*api.FormData, Options) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
form := ctx.FormData().
|
form := ctx.FormData().
|
||||||
String("userAgent", &userAgent, defaultOptions.UserAgent).
|
|
||||||
Duration("waitDelay", &waitDelay, defaultOptions.WaitDelay).
|
Duration("waitDelay", &waitDelay, defaultOptions.WaitDelay).
|
||||||
String("waitWindowStatus", &waitWindowStatus, defaultOptions.WaitWindowStatus).
|
String("waitWindowStatus", &waitWindowStatus, defaultOptions.WaitWindowStatus).
|
||||||
|
String("userAgent", &userAgent, defaultOptions.UserAgent).
|
||||||
Custom("extraHttpHeaders", func(value string) error {
|
Custom("extraHttpHeaders", func(value string) error {
|
||||||
if value == "" {
|
if value == "" {
|
||||||
extraHTTPHeaders = defaultOptions.ExtraHTTPHeaders
|
extraHTTPHeaders = defaultOptions.ExtraHTTPHeaders
|
||||||
@@ -71,9 +71,9 @@ func FormDataChromiumPDFOptions(ctx *api.Context) (*api.FormData, Options) {
|
|||||||
Bool("preferCssPageSize", &preferCSSPageSize, defaultOptions.PreferCSSPageSize)
|
Bool("preferCssPageSize", &preferCSSPageSize, defaultOptions.PreferCSSPageSize)
|
||||||
|
|
||||||
options := Options{
|
options := Options{
|
||||||
UserAgent: userAgent,
|
|
||||||
WaitDelay: waitDelay,
|
WaitDelay: waitDelay,
|
||||||
WaitWindowStatus: waitWindowStatus,
|
WaitWindowStatus: waitWindowStatus,
|
||||||
|
UserAgent: userAgent,
|
||||||
ExtraHTTPHeaders: extraHTTPHeaders,
|
ExtraHTTPHeaders: extraHTTPHeaders,
|
||||||
Landscape: landscape,
|
Landscape: landscape,
|
||||||
PrintBackground: printBackground,
|
PrintBackground: printBackground,
|
||||||
|
|||||||
Reference in New Issue
Block a user