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