From db6cddefd4834997ba1b61c0fec51a6ae565c7ef Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Tue, 20 Aug 2019 16:20:42 +0200 Subject: [PATCH] updating documentation according to changes --- Makefile | 1 - README.md | 5 +- build/docs/content/01-install.md | 11 +- build/docs/content/02-clients.md | 2 +- .../docs/content/03-environment-variables.md | 58 ++++- build/docs/content/04-html.md | 10 +- build/docs/content/05-url.md | 2 +- build/docs/content/06-markdown.md | 2 +- build/docs/content/07-office.md | 4 +- build/docs/content/08-merge.md | 6 +- build/docs/content/09-timeout.md | 2 +- build/docs/content/10-webhook.md | 54 ++++- build/docs/content/11-result-filename.md | 2 +- build/docs/content/12-scalability.md | 2 +- build/docs/content/13-ping.md | 30 ++- docs/index.html | 212 +++++++++++++++--- 16 files changed, 328 insertions(+), 75 deletions(-) diff --git a/Makefile b/Makefile index c6d9d631..85ec5f69 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,6 @@ tests: # generate documentation. doc: - make workspace docker build -t $(DOCKER_REPOSITORY)/gotenberg:docs -f build/docs/Dockerfile . docker run --rm -it -v "$(PWD):/gotenberg/docs" $(DOCKER_REPOSITORY)/gotenberg:docs diff --git a/README.md b/README.md index 8d5bbd74..210d83b3 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ At TheCodingMachine, we build a lot of web applications (intranets, extranets an Open a terminal and run the following command: ```bash -$ docker run --rm -p 3000:3000 thecodingmachine/gotenberg:5 +$ docker run --rm -p 3000:3000 thecodingmachine/gotenberg:6 ``` The API is now available on your host at `http://localhost:3000`. @@ -33,9 +33,10 @@ to learn how to interact with it! ## Badges -[![Docker image layers](https://images.microbadger.com/badges/image/thecodingmachine/gotenberg:5.svg)](https://microbadger.com/images/thecodingmachine/gotenberg:5) +[![Docker image layers](https://images.microbadger.com/badges/image/thecodingmachine/gotenberg:6.svg)](https://microbadger.com/images/thecodingmachine/gotenberg:6) [![Actions Status](https://github.com/thecodingmachine/gotenberg/workflows/Push/badge.svg)](https://github.com/thecodingmachine/gotenberg/actions) [![GoDoc](https://godoc.org/github.com/thecodingmachine/gotenberg?status.svg)](https://godoc.org/github.com/thecodingmachine/gotenberg) +[![Codecov](https://codecov.io/gh/thecodingmachine/gotenberg/branch/master/graph/badge.svg)](https://codecov.io/gh/thecodingmachine/gotenberg) [![Go Report Card](https://goreportcard.com/badge/github.com/thecodingmachine/gotenberg)](https://goreportcard.com/report/thecodingmachine/gotenberg) --- diff --git a/build/docs/content/01-install.md b/build/docs/content/01-install.md index cc29d1ba..9e344f20 100644 --- a/build/docs/content/01-install.md +++ b/build/docs/content/01-install.md @@ -4,14 +4,14 @@ title: Install Gotenberg is shipped within a Docker image. +> It uses a dedicated non-root user called `gotenberg` with uid and gid `1001`. + You may start it with: ```bash -$ docker run --rm -p 3000:3000 thecodingmachine/gotenberg:5 +$ docker run --rm -p 3000:3000 thecodingmachine/gotenberg:6 ``` -All processes in the Docker container runs as a dedicated non-root user called `gotenberg` with user id `1001` from the working dir `/gotenberg`. - > The API will be available at [http://localhost:3000](http://localhost:3000). ## Docker Compose @@ -26,7 +26,7 @@ services: # your others services gotenberg: - image: thecodingmachine/gotenberg:5 + image: thecodingmachine/gotenberg:6 ``` > The API will be available under `gotenberg:3000` in your Docker Compose network. @@ -40,7 +40,8 @@ Otherwise the API will not be able to launch Google Chrome and LibreOffice (unoc > The more resources are granted, the quicker will be the conversions. -Also, in the deployment spec of the pod, specify the uid `1001` of the user `gotenberg`: +In the deployment specification of the pod, also specify the uid `1001` of the user `gotenberg`: + ``` securityContext: privileged: false diff --git a/build/docs/content/02-clients.md b/build/docs/content/02-clients.md index 195fb85d..59ecd1e6 100644 --- a/build/docs/content/02-clients.md +++ b/build/docs/content/02-clients.md @@ -7,7 +7,7 @@ We provide clients in various languages for easing the interactions with the API ## Go client ```bash -$ go get -u github.com/thecodingmachine/gotenberg-go-client/v5 +$ go get -u github.com/thecodingmachine/gotenberg-go-client/v6 ``` ## PHP client diff --git a/build/docs/content/03-environment-variables.md b/build/docs/content/03-environment-variables.md index a9f75d32..0aedc995 100644 --- a/build/docs/content/03-environment-variables.md +++ b/build/docs/content/03-environment-variables.md @@ -4,6 +4,25 @@ title: Environment variables You may customize the API behaviour thanks to environment variables. +## Log level + +The API provides structured logging allowing you to have relevant information +about what's going on. + +> If a TTY is attached, the log entries are displayed in text format with colors, otherwise in JSON format. + +You may customize the severity of the log entries thanks to the environment variable `LOG_LEVEL`. + +It accepts one of the following severities: `"DEBUG"`, `"INFO"` (default) and `"ERROR"`. + +## Default listen port + +By default, the API will listen on port `3000`. + +You may customize this value with the environment variable `DEFAULT_LISTEN_PORT`. + +This environment variable accepts any string that can be turned into a port number. + ## Disable Google Chrome In order to save some resources, the Gotenberg image accepts the environment variable `DISABLE_GOOGLE_CHROME`. @@ -31,26 +50,41 @@ It takes a string representation of a float as value (e.g `"2.5"` for 2.5 second > The default timeout may also be overridden per request thanks to the form field `waitTimeout`. > See the [timeout section](#timeout). -## Disable logging on healthcheck +## Maximum wait timeout -By default, the API will add a log entry when the [healthcheck endpoint](#ping) is called. +By default, the value of the form field `waitTimeout` cannot be more than 30 seconds. -You may turn off this logging so as to avoid unnecessary entries in your logs with the environment variable `DISABLE_HEALTHCHECK_LOGGING`. +You may increase or decrease this limit thanks to the environment variable `MAXIMUM_WAIT_TIMEOUT`. -This environment variable operates in the same manner as the `DISABLE_GOOGLE_CHROME` and `DISABLE_UNOCONV` variables operate in that it accepts the strings `"0"` or `"1"` as values, where `"1"` is enabled. +It takes a string representation of a float as value (e.g `"2.5"` for 2.5 seconds). -## Default listen port +## Default webhook URL timeout -By default, the API will listen on port `3000`. For most use cases this is perfectly fine, but at times there may be cases where you need to change this due to port conflicts. +By default, the API will wait 10 seconds before it considers the sending of the resulting PDF to be unsuccessful. -You may customize this port location with the environment variable `DEFAULT_LISTEN_PORT`. +> See the [webhook section](#webhook). -This environment variable accepts any string that can be turned into a port number (e.g., the string `"0"` up to the string `"65535"`). +You may customize this timeout thanks to the environment variable `DEFAULT_WEBHOOK_URL_TIMEOUT`. -## Debug logging of process startup +It takes a string representation of a float as value (e.g `"2.5"` for 2.5 seconds). -By default, `stdout` and `stderr` messages from the started processes are disabled. +> The default timeout may also be overridden per request thanks to the form field `webhookURLTimeout`. +> See the [webhook timeout section](#webhook.timeout). -You may enable some debug logging from starting the process by setting the environment variable `DEBUG_PROCESS_STARTUP`. +## Maximum webhook URL timeout -This environment variable operates in the same manner as the `DISABLE_GOOGLE_CHROME` and `DISABLE_UNOCONV` variables operate in that it accepts the strings `"0"` or `"1"` as values, where `1` means `true`. +By default, the value of the form field `webhookURLTimeout` cannot be more than 30 seconds. + +You may increase or decrease this limit thanks to the environment variable `MAXIMUM_WEBHOOK_URL_TIMEOUT`. + +It takes a string representation of a float as value (e.g `"2.5"` for 2.5 seconds). + +## Maximum wait delay + +By default, the value of the form field `waitDelay` cannot be more than 10 seconds. + +> See the [wait delay section](#html.wait_delay). + +You may increase or decrease this limit thanks to the environment variable `MAXIMUM_WAIT_DELAY`. + +It takes a string representation of a float as value (e.g `"2.5"` for 2.5 seconds). diff --git a/build/docs/content/04-html.md b/build/docs/content/04-html.md index 4fdb6741..8f1e5070 100644 --- a/build/docs/content/04-html.md +++ b/build/docs/content/04-html.md @@ -39,7 +39,7 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v5" +import "github.com/thecodingmachine/gotenberg-go-client/v6" func main() { c := &gotenberg.Client{Hostname: "http://localhost:3000"} @@ -113,7 +113,7 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v5" +import "github.com/thecodingmachine/gotenberg-go-client/v6" func main() { c := &gotenberg.Client{Hostname: "http://localhost:3000"} @@ -203,7 +203,7 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v5" +import "github.com/thecodingmachine/gotenberg-go-client/v6" func main() { c := &gotenberg.Client{Hostname: "http://localhost:3000"} @@ -262,7 +262,7 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v5" +import "github.com/thecodingmachine/gotenberg-go-client/v6" func main() { c := &gotenberg.Client{Hostname: "http://localhost:3000"} @@ -315,7 +315,7 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v5" +import "github.com/thecodingmachine/gotenberg-go-client/v6" func main() { c := &gotenberg.Client{Hostname: "http://localhost:3000"} diff --git a/build/docs/content/05-url.md b/build/docs/content/05-url.md index a26db834..6517843a 100644 --- a/build/docs/content/05-url.md +++ b/build/docs/content/05-url.md @@ -31,7 +31,7 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v5" +import "github.com/thecodingmachine/gotenberg-go-client/v6" func main() { c := &gotenberg.Client{Hostname: "http://localhost:3000"} diff --git a/build/docs/content/06-markdown.md b/build/docs/content/06-markdown.md index 1dadb7c5..66c50ee4 100644 --- a/build/docs/content/06-markdown.md +++ b/build/docs/content/06-markdown.md @@ -42,7 +42,7 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v5" +import "github.com/thecodingmachine/gotenberg-go-client/v6" func main() { c := &gotenberg.Client{Hostname: "http://localhost:3000"} diff --git a/build/docs/content/07-office.md b/build/docs/content/07-office.md index b17b8146..3a2f7fbd 100644 --- a/build/docs/content/07-office.md +++ b/build/docs/content/07-office.md @@ -43,7 +43,7 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v5" +import "github.com/thecodingmachine/gotenberg-go-client/v6" func main() { c := &gotenberg.Client{Hostname: "http://localhost:3000"} @@ -90,7 +90,7 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v5" +import "github.com/thecodingmachine/gotenberg-go-client/v6" func main() { c := &gotenberg.Client{Hostname: "http://localhost:3000"} diff --git a/build/docs/content/08-merge.md b/build/docs/content/08-merge.md index 3b8b7dfc..59a3e4d8 100644 --- a/build/docs/content/08-merge.md +++ b/build/docs/content/08-merge.md @@ -2,7 +2,7 @@ title: Merge --- -Gotenberg provides the endpoint `/convert/merge` for merging PDFs. +Gotenberg provides the endpoint `/merge` for merging PDFs. It accepts `POST` requests with a `multipart/form-data` Content-Type. @@ -17,7 +17,7 @@ will merge them and return the resulting PDF file. ```bash $ curl --request POST \ - --url http://localhost:3000/convert/merge \ + --url http://localhost:3000/merge \ --header 'Content-Type: multipart/form-data' \ --form files=@file.pdf \ --form files=@file2.pdf \ @@ -27,7 +27,7 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v5" +import "github.com/thecodingmachine/gotenberg-go-client/v6" func main() { c := &gotenberg.Client{Hostname: "http://localhost:3000"} diff --git a/build/docs/content/09-timeout.md b/build/docs/content/09-timeout.md index 92c78b83..a97ee0fd 100644 --- a/build/docs/content/09-timeout.md +++ b/build/docs/content/09-timeout.md @@ -25,7 +25,7 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v5" +import "github.com/thecodingmachine/gotenberg-go-client/v6" func main() { c := &gotenberg.Client{Hostname: "http://localhost:3000"} diff --git a/build/docs/content/10-webhook.md b/build/docs/content/10-webhook.md index 497baaca..b94743ba 100644 --- a/build/docs/content/10-webhook.md +++ b/build/docs/content/10-webhook.md @@ -24,7 +24,7 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v5" +import "github.com/thecodingmachine/gotenberg-go-client/v6" func main() { c := &gotenberg.Client{Hostname: "http://localhost:3000"} @@ -46,4 +46,56 @@ $index = DocumentFactory::makeFromPath('index.html', 'index.html'); $request = new HTMLRequest($index); $request->setWebhookURL('http://myapp.com/webhook/'); $resp = $client->post($request); +``` + +## Timeout + +If a `webhookURL` is provided, you may also send a form field named `webhookURLTimeout`. + +The API will wait the given **seconds** before it considers the sending of the resulting PDF to be unsucessful. + +It takes a float as value (e.g `2.5` for 2.5 seconds). + +> You may also define this value globally: see the [environment variables](#environment_variables.default_webhook_url_timeout) section. + +### Examples + +#### cURL + +```bash +$ curl --request POST \ + --url http://localhost:3000/convert/html \ + --header 'Content-Type: multipart/form-data' \ + --form files=@index.html \ + --form webhookURL='http://myapp.com/webhook/' \ + --form webhookURLTimeout=2.5 +``` + +#### Go + +```golang +import "github.com/thecodingmachine/gotenberg-go-client/v6" + +func main() { + c := &gotenberg.Client{Hostname: "http://localhost:3000"} + req, _ := gotenberg.NewHTMLRequest("index.html") + req.WebhookURL("http://myapp.com/webhook/") + req.WebhookURLTimeout(2.5) + resp, _ := c.Post(req) +} +``` + +#### PHP + +```php +use TheCodingMachine\Gotenberg\Client; +use TheCodingMachine\Gotenberg\DocumentFactory; +use TheCodingMachine\Gotenberg\HTMLRequest; + +$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client()); +$index = DocumentFactory::makeFromPath('index.html', 'index.html'); +$request = new HTMLRequest($index); +$request->setWebhookURL('http://myapp.com/webhook/'); +$request->setWebhookURLTimeout(2.5); +$resp = $client->post($request); ``` \ No newline at end of file diff --git a/build/docs/content/11-result-filename.md b/build/docs/content/11-result-filename.md index 22f2c184..634962e7 100644 --- a/build/docs/content/11-result-filename.md +++ b/build/docs/content/11-result-filename.md @@ -24,7 +24,7 @@ $ curl --request POST \ ### Go ```golang -import "github.com/thecodingmachine/gotenberg-go-client/v5" +import "github.com/thecodingmachine/gotenberg-go-client/v6" func main() { c := &gotenberg.Client{Hostname: "http://localhost:3000"} diff --git a/build/docs/content/12-scalability.md b/build/docs/content/12-scalability.md index e5d1225f..a58c329c 100644 --- a/build/docs/content/12-scalability.md +++ b/build/docs/content/12-scalability.md @@ -14,7 +14,7 @@ services: # your others services gotenberg: - image: thecodingmachine/gotenberg:5 + image: thecodingmachine/gotenberg:6 ``` You may now launch your services using: diff --git a/build/docs/content/13-ping.md b/build/docs/content/13-ping.md index 3222cf55..2d06f605 100644 --- a/build/docs/content/13-ping.md +++ b/build/docs/content/13-ping.md @@ -8,4 +8,32 @@ a simple `GET` request. This feature is especially useful for liveness/readiness probes in Kubernetes: * [Pod lifecycle](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes) -* [Configure Liveness and Readiness Probes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/) \ No newline at end of file +* [Configure Liveness and Readiness Probes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/) + +If `LOG_LEVEL` is `"DEBUG"`, it also returns details about the PM2 processes in JSON format. +For instance: + +```json +[ + { + "name": "google-chrome-stable", + "pm2_env": { + "status": "online" + }, + "monit": { + "memory": 73826304, + "cpu": 0 + } + }, + { + "name": "unoconv", + "pm2_env": { + "status": "online" + }, + "monit": { + "memory": 70914048, + "cpu": 0 + } + } +] +``` diff --git a/docs/index.html b/docs/index.html index 47e58226..931fe869 100755 --- a/docs/index.html +++ b/docs/index.html @@ -134,13 +134,15 @@ Install

Gotenberg is shipped within a Docker image.

+
+

It uses a dedicated non-root user called gotenberg with uid and gid 1001.

+
+

You may start it with:

-
$ docker run --rm -p 3000:3000 thecodingmachine/gotenberg:5
+
$ docker run --rm -p 3000:3000 thecodingmachine/gotenberg:6
 
-

All processes in the Docker container runs as a dedicated non-root user called gotenberg with user id 1001 from the working dir /gotenberg.

-

The API will be available at http://localhost:3000.

@@ -158,7 +160,7 @@ # your others services gotenberg: - image: thecodingmachine/gotenberg:5 + image: thecodingmachine/gotenberg:6
@@ -178,7 +180,7 @@ Otherwise the API will not be able to launch Google Chrome and LibreOffice (unoc

The more resources are granted, the quicker will be the conversions.

-

Also, in the deployment spec of the pod, specify the uid 1001 of the user gotenberg:

+

In the deployment specification of the pod, also specify the uid 1001 of the user gotenberg:

securityContext:
   privileged: false
@@ -200,7 +202,7 @@ Gotenberg API is available at http://localhost:3
 	
 Go client
 
-
$ go get -u github.com/thecodingmachine/gotenberg-go-client/v5
+
$ go get -u github.com/thecodingmachine/gotenberg-go-client/v6
 

http://localhost:3 Environment variables

You may customize the API behaviour thanks to environment variables.

+

Log level

+ +

The API provides structured logging allowing you to have relevant information +about what’s going on.

+ +
+

If a TTY is attached, the log entries are displayed in text format with colors, otherwise in JSON format.

+
+ +

You may customize the severity of the log entries thanks to the environment variable LOG_LEVEL.

+ +

It accepts one of the following severities: "DEBUG", "INFO" (default) and "ERROR".

+ +

Default listen port

+ +

By default, the API will listen on port 3000.

+ +

You may customize this value with the environment variable DEFAULT_LISTEN_PORT.

+ +

This environment variable accepts any string that can be turned into a port number.

+

Disable Google Chrome

@@ -264,35 +291,58 @@ Gotenberg API is available at http://localhost:3 See the timeout section.

-

Disable logging on healthcheck

+Maximum wait timeout

-

By default, the API will add a log entry when the healthcheck endpoint is called.

+

By default, the value of the form field waitTimeout cannot be more than 30 seconds.

-

You may turn off this logging so as to avoid unnecessary entries in your logs with the environment variable DISABLE_HEALTHCHECK_LOGGING.

+

You may increase or decrease this limit thanks to the environment variable MAXIMUM_WAIT_TIMEOUT.

-

This environment variable operates in the same manner as the DISABLE_GOOGLE_CHROME and DISABLE_UNOCONV variables operate in that it accepts the strings "0" or "1" as values, where "1" is enabled.

+

It takes a string representation of a float as value (e.g "2.5" for 2.5 seconds).

-

Default listen port

+Default webhook URL timeout

-

By default, the API will listen on port 3000. For most use cases this is perfectly fine, but at times there may be cases where you need to change this due to port conflicts.

+

By default, the API will wait 10 seconds before it considers the sending of the resulting PDF to be unsuccessful.

-

You may customize this port location with the environment variable DEFAULT_LISTEN_PORT.

+
+

See the webhook section.

+
-

This environment variable accepts any string that can be turned into a port number (e.g., the string "0" up to the string "65535").

+

You may customize this timeout thanks to the environment variable DEFAULT_WEBHOOK_URL_TIMEOUT.

-

webhook timeout section.

+
+ +

Debug logging of process startup

+Maximum webhook URL timeout -

By default, stdout and stderr messages from the started processes are disabled.

+

By default, the value of the form field webhookURLTimeout cannot be more than 30 seconds.

-

You may enable some debug logging from starting the process by setting the environment variable DEBUG_PROCESS_STARTUP.

+

You may increase or decrease this limit thanks to the environment variable MAXIMUM_WEBHOOK_URL_TIMEOUT.

-

This environment variable operates in the same manner as the DISABLE_GOOGLE_CHROME and DISABLE_UNOCONV variables operate in that it accepts the strings "0" or "1" as values, where 1 means true.

+

It takes a string representation of a float as value (e.g "2.5" for 2.5 seconds).

+ +

Maximum wait delay

+ +

By default, the value of the form field waitDelay cannot be more than 10 seconds.

+ +
+

See the wait delay section.

+
+ +

You may increase or decrease this limit thanks to the environment variable MAXIMUM_WAIT_DELAY.

+ +

It takes a string representation of a float as value (e.g "2.5" for 2.5 seconds).

@@ -340,7 +390,7 @@ which will be converted to PDF.

Go -
import "github.com/thecodingmachine/gotenberg-go-client/v5"
+
import "github.com/thecodingmachine/gotenberg-go-client/v6"
 
 func main() {
     c := &gotenberg.Client{Hostname: "http://localhost:3000"}
@@ -422,7 +472,7 @@ Also, footer.html CSS properties override the ones from heade
 	
 Go
 
-
import "github.com/thecodingmachine/gotenberg-go-client/v5"
+
import "github.com/thecodingmachine/gotenberg-go-client/v6"
 
 func main() {
     c := &gotenberg.Client{Hostname: "http://localhost:3000"}
@@ -517,7 +567,7 @@ see to the fonts section.

Go -
import "github.com/thecodingmachine/gotenberg-go-client/v5"
+
import "github.com/thecodingmachine/gotenberg-go-client/v6"
 
 func main() {
     c := &gotenberg.Client{Hostname: "http://localhost:3000"}
@@ -583,7 +633,7 @@ $client->store($request, $dest);
 	
 Go
 
-
import "github.com/thecodingmachine/gotenberg-go-client/v5"
+
import "github.com/thecodingmachine/gotenberg-go-client/v6"
 
 func main() {
     c := &gotenberg.Client{Hostname: "http://localhost:3000"}
@@ -643,7 +693,7 @@ a lot on JavaScript for rendering.

Go -
import "github.com/thecodingmachine/gotenberg-go-client/v5"
+
import "github.com/thecodingmachine/gotenberg-go-client/v6"
 
 func main() {
     c := &gotenberg.Client{Hostname: "http://localhost:3000"}
@@ -712,7 +762,7 @@ If not, some of the content of the page might be hidden.

Go -
import "github.com/thecodingmachine/gotenberg-go-client/v5"
+
import "github.com/thecodingmachine/gotenberg-go-client/v6"
 
 func main() {
     c := &gotenberg.Client{Hostname: "http://localhost:3000"}
@@ -786,7 +836,7 @@ in the file index.html. This function will convert a given markdown
 	
 Go
 
-
import "github.com/thecodingmachine/gotenberg-go-client/v5"
+
import "github.com/thecodingmachine/gotenberg-go-client/v6"
 
 func main() {
     c := &gotenberg.Client{Hostname: "http://localhost:3000"}
@@ -869,7 +919,7 @@ See the scalability section to find how to mitigate t
 	
 Go
 
-
import "github.com/thecodingmachine/gotenberg-go-client/v5"
+
import "github.com/thecodingmachine/gotenberg-go-client/v6"
 
 func main() {
     c := &gotenberg.Client{Hostname: "http://localhost:3000"}
@@ -921,7 +971,7 @@ $client->store($request, $dest);
 	
 Go
 
-
import "github.com/thecodingmachine/gotenberg-go-client/v5"
+
import "github.com/thecodingmachine/gotenberg-go-client/v6"
 
 func main() {
     c := &gotenberg.Client{Hostname: "http://localhost:3000"}
@@ -956,7 +1006,7 @@ $client->store($request, $dest);
                 

Merge

-

Gotenberg provides the endpoint /convert/merge for merging PDFs.

+

Gotenberg provides the endpoint /merge for merging PDFs.

It accepts POST requests with a multipart/form-data Content-Type.

@@ -976,7 +1026,7 @@ will merge them and return the resulting PDF file.

cURL
$ curl --request POST \
-    --url http://localhost:3000/convert/merge \
+    --url http://localhost:3000/merge \
     --header 'Content-Type: multipart/form-data' \
     --form files=@file.pdf \
     --form files=@file2.pdf \
@@ -987,7 +1037,7 @@ will merge them and return the resulting PDF file.

Go -
import "github.com/thecodingmachine/gotenberg-go-client/v5"
+
import "github.com/thecodingmachine/gotenberg-go-client/v6"
 
 func main() {
     c := &gotenberg.Client{Hostname: "http://localhost:3000"}
@@ -1050,7 +1100,7 @@ $client->store($request, $dest);
 	
 Go
 
-
import "github.com/thecodingmachine/gotenberg-go-client/v5"
+
import "github.com/thecodingmachine/gotenberg-go-client/v6"
 
 func main() {
     c := &gotenberg.Client{Hostname: "http://localhost:3000"}
@@ -1109,7 +1159,7 @@ to given URL.

Go -
import "github.com/thecodingmachine/gotenberg-go-client/v5"
+
import "github.com/thecodingmachine/gotenberg-go-client/v6"
 
 func main() {
     c := &gotenberg.Client{Hostname: "http://localhost:3000"}
@@ -1132,6 +1182,67 @@ $index = DocumentFactory::makeFromPath('index.html', 'index.html'
 $request = new HTMLRequest($index);
 $request->setWebhookURL('http://myapp.com/webhook/');
 $resp = $client->post($request);
+
+ +

Timeout

+ +

If a webhookURL is provided, you may also send a form field named webhookURLTimeout.

+ +

The API will wait the given seconds before it considers the sending of the resulting PDF to be unsucessful.

+ +

It takes a float as value (e.g 2.5 for 2.5 seconds).

+ +
+

You may also define this value globally: see the environment variables section.

+
+ +

Examples

+ +

cURL

+ +
$ curl --request POST \
+    --url http://localhost:3000/convert/html \
+    --header 'Content-Type: multipart/form-data' \
+    --form files=@index.html \
+    --form webhookURL='http://myapp.com/webhook/' \
+    --form webhookURLTimeout=2.5
+
+ +

Go

+ +
import "github.com/thecodingmachine/gotenberg-go-client/v6"
+
+func main() {
+    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
+    req, _ := gotenberg.NewHTMLRequest("index.html")
+    req.WebhookURL("http://myapp.com/webhook/")
+    req.WebhookURLTimeout(2.5)
+    resp, _ := c.Post(req)
+}
+
+ +

PHP

+ +
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\HTMLRequest;
+
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$index = DocumentFactory::makeFromPath('index.html', 'index.html');
+$request = new HTMLRequest($index);
+$request->setWebhookURL('http://myapp.com/webhook/');
+$request->setWebhookURLTimeout(2.5);
+$resp = $client->post($request);
 
@@ -1168,7 +1279,7 @@ Otherwise a random filename is used.

Go -
import "github.com/thecodingmachine/gotenberg-go-client/v5"
+
import "github.com/thecodingmachine/gotenberg-go-client/v6"
 
 func main() {
     c := &gotenberg.Client{Hostname: "http://localhost:3000"}
@@ -1211,7 +1322,7 @@ $resp = $client->post($request);
   # your others services
 
   gotenberg:
-    image: thecodingmachine/gotenberg:5
+    image: thecodingmachine/gotenberg:6
 

You may now launch your services using:

@@ -1238,6 +1349,33 @@ a simple GET request.

  • Configure Liveness and Readiness Probes
  • +

    If LOG_LEVEL is "DEBUG", it also returns details about the PM2 processes in JSON format. +For instance:

    + +
    [
    +    {
    +        "name": "google-chrome-stable",
    +        "pm2_env": {
    +            "status": "online"
    +        },
    +        "monit": {
    +            "memory": 73826304,
    +            "cpu": 0
    +        }
    +    },
    +    {
    +        "name": "unoconv",
    +        "pm2_env": {
    +            "status": "online"
    +        },
    +        "monit": {
    +            "memory": 70914048,
    +            "cpu": 0
    +        }
    +    }
    +]
    +
    +