Descriptor returns an [Api]'s module descriptor.
()
| 182 | |
| 183 | // Descriptor returns an [Api]'s module descriptor. |
| 184 | func (a *Api) Descriptor() gotenberg.ModuleDescriptor { |
| 185 | return gotenberg.ModuleDescriptor{ |
| 186 | ID: "api", |
| 187 | FlagSet: func() *flag.FlagSet { |
| 188 | fs := flag.NewFlagSet("api", flag.ExitOnError) |
| 189 | fs.Int("api-port", 3000, "Set the port on which the API should listen") |
| 190 | fs.String("api-port-from-env", "", "Set the environment variable with the port on which the API should listen - override the default port") |
| 191 | fs.String("api-bind-ip", "", "Set the IP address the API should bind to for incoming connections") |
| 192 | fs.String("api-tls-cert-file", "", "Path to the TLS/SSL certificate file - for HTTPS support") |
| 193 | fs.String("api-tls-key-file", "", "Path to the TLS/SSL key file - for HTTPS support") |
| 194 | fs.Duration("api-start-timeout", time.Duration(30)*time.Second, "Set the time limit for the API to start") |
| 195 | fs.Duration("api-timeout", time.Duration(30)*time.Second, "Set the time limit for requests") |
| 196 | fs.String("api-body-limit", "", "Set the body limit for multipart/form-data requests - it accepts values like 5MB, 1GB, etc") |
| 197 | fs.String("api-root-path", "/", "Set the root path of the API - for service discovery via URL paths") |
| 198 | fs.String("api-correlation-id-header", "Gotenberg-Trace", "Set the header name to use for identifying requests") |
| 199 | fs.Bool("api-enable-basic-auth", false, "Enable basic authentication - will look for the GOTENBERG_API_BASIC_AUTH_USERNAME and GOTENBERG_API_BASIC_AUTH_PASSWORD environment variables") |
| 200 | fs.StringSlice("api-download-from-allow-list", []string{}, "Set the allowed URLs for the download from feature using regular expressions - supports multiple values") |
| 201 | fs.StringSlice("api-download-from-deny-list", []string{}, "Set the denied URLs for the download from feature using regular expressions - supports multiple values") |
| 202 | fs.Bool("api-download-from-deny-private-ips", false, "Reject downloadFrom URLs whose host resolves to a non-public IP address (loopback, RFC1918, link-local, unique-local). Enable on deployments that accept untrusted downloadFrom sources to mitigate SSRF against internal services") |
| 203 | fs.Bool("api-download-from-deny-public-ips", false, "Reject downloadFrom URLs whose host resolves to a public IP address. Enable on air-gapped or data-governed deployments to prevent downloads from reaching the public internet") |
| 204 | fs.Int("api-download-from-max-retry", 4, "Set the maximum number of retries for the download from feature") |
| 205 | fs.Bool("api-disable-download-from", false, "Disable the download from feature") |
| 206 | fs.Bool("api-disable-health-check-route-telemetry", true, "Disable telemetry for health check route") |
| 207 | fs.Bool("api-disable-root-route-telemetry", true, "Disable telemetry for the root route") |
| 208 | fs.Bool("api-disable-debug-route-telemetry", true, "Disable telemetry for the debug route") |
| 209 | fs.Bool("api-disable-version-route-telemetry", true, "Disable telemetry for the version route") |
| 210 | fs.Bool("api-enable-debug-route", false, "Enable the debug route") |
| 211 | |
| 212 | // Deprecated flags. |
| 213 | fs.String("api-trace-header", "Gotenberg-Trace", "Set the header name to use for identifying requests") |
| 214 | fs.Bool("api-disable-health-check-logging", false, "Disable health check logging") |
| 215 | |
| 216 | err := errors.Join( |
| 217 | fs.MarkDeprecated("api-trace-header", "use --api-correlation-id-header instead"), |
| 218 | fs.MarkDeprecated("api-disable-health-check-logging", "use --api-disable-health-check-route-telemetry instead"), |
| 219 | ) |
| 220 | if err != nil { |
| 221 | panic(err) |
| 222 | } |
| 223 | return fs |
| 224 | }(), |
| 225 | New: func() gotenberg.Module { return new(Api) }, |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | // Provision sets the module properties. |
| 230 | func (a *Api) Provision(ctx *gotenberg.Context) error { |