stdgotenbergfx

package
v0.0.265 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package stdgotenbergfx provides a client of Gotenberg (https://gotenberg.dev), which converts documents as a service of its own, so no document is processed in Go.

Gotenberg reads and writes the files itself, with requests that the caller pre-signs (stds3fx): it downloads its input (downloadFrom) and uploads its output (its webhook), so file contents pass through neither the service nor its workers. Run Gotenberg with WEBHOOK_ENABLE_SYNC_MODE, so a conversion returns once the upload is done.

Gotenberg answers a conversion the same whether its upload succeeded or not, and reports why only to its events URL: callers check that the output arrived.

Index

Constants

This section is empty.

Variables

View Source
var ErrRejected = errors.New("stdgotenbergfx: rejected")

ErrRejected reports that Gotenberg refused a conversion, such as of a file it cannot download; sending it again fails the same way.

Functions

func Provide

func Provide() fx.Option

Provide wires the module. It needs the *http.Client of stdhttpclientfx.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client converts documents with Gotenberg. It is safe for concurrent use.

func New

func New(cfg Config, client *http.Client) *Client

New builds the client, which sends its requests with client, such as that of stdhttpclientfx.

func (*Client) ConvertOffice

func (c *Client) ConvertOffice(ctx context.Context, source, target *stds3fx.PresignedRequest) error

ConvertOffice has Gotenberg convert the office document that source downloads into a PDF with LibreOffice, and upload it with target, a pre-signed PUT. Source's response must name the file (Content-Disposition), whose extension tells Gotenberg the format. It returns once Gotenberg is done, but Gotenberg answers the same whether the upload succeeded or not: callers check the output.

It fails with ErrRejected when Gotenberg refuses the request, such as when it cannot download source.

type Config

type Config struct {
	// URL is where the service reaches Gotenberg's API.
	URL string `env:"URL,required"`
}

Config configures the module, from the environment with the STDGOTENBERG_ prefix.

Directories

Path Synopsis
Package stdgotenbergtestfx provides the stdgotenbergfx client for tests, on a Gotenberg server that is started for the tests (stdtestcontainer.Gotenberg), so they need no Docker Compose or other prior setup.
Package stdgotenbergtestfx provides the stdgotenbergfx client for tests, on a Gotenberg server that is started for the tests (stdtestcontainer.Gotenberg), so they need no Docker Compose or other prior setup.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL