Skip to content

Commit

Permalink
feat: return v8 in module name
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Pikeev committed Oct 31, 2024
1 parent e1ceb9a commit 7e69df8
Show file tree
Hide file tree
Showing 20 changed files with 71 additions and 64 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ GOTENBERG_VERSION=8.12.0
GOTENBERG_LOG_LEVEL=ERROR
VERSION=snapshot
GOLANGCI_LINT_VERSION=1.61.0
REPO=dcaraxes/gotenberg-go-client
REPO=dcaraxes/gotenberg-go-client/v8

# gofmt and goimports all go files.
fmt:
Expand Down
85 changes: 46 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<p align="center">
<h1 align="center">Gotenberg Go Client</h1>
<p align="center">The Go client for interacting with a Gotenberg API. This project is a further development of the <a href="https://github.com/thecodingmachine/gotenberg-go-client">client from TheCodingMachine</a>, which does not support the new functionality since version 7 of Gotenberg.
</p>
</p>

---

|Gotenberg version |Client version |
|:----------------:|:---------------------------------------------------------------------------------------------------------:|
|`8.x` **(actual)**|`8.6.2` **(actual)** |
|`7.x` |`<= 8.5.0` |
|`6.x` |<a href="https://github.com/thecodingmachine/gotenberg-go-client">thecodingmachine/gotenberg-go-client</a> |
|Gotenberg version | Client version |
|:----------------:|:----------------------------------------------------------------------------------------------------------:|
|`8.x` **(actual)**| `8.6.3` **(actual)** <br/> |
|`7.x` | `<= 8.5.0` |
|`6.x` | <a href="https://github.com/thecodingmachine/gotenberg-go-client">thecodingmachine/gotenberg-go-client</a> |

---

Expand All @@ -19,7 +18,7 @@
To get the latest version of the client:

```zsh
$ go get github.com/dcaraxes/gotenberg-go-client@latest
$ go get github.com/dcaraxes/gotenberg-go-client/v8@latest
```

## Preparing a documents
Expand All @@ -28,10 +27,11 @@ $ go get github.com/dcaraxes/gotenberg-go-client@latest
package main

import (
"net/http"
"os"

"github.com/dcaraxes/gotenberg-go-client"
"github.com/dcaraxes/gotenberg-go-client/document"
"github.com/dcaraxes/gotenberg-go-client/v8"
"github.com/dcaraxes/gotenberg-go-client/v8/document"
)

func main() {
Expand All @@ -51,7 +51,9 @@ func main() {
## Converting HTML to PDF

> [!TIP]
> Head to the [documentation](https://gotenberg.dev/) to learn about all request parameters. For the PaperSize method, you can use predefined parameters such as gotenberg.A4, gotenberg.A3 and so on. The full list of predefined parameters can be found in [types file](https://github.com/dcaraxes/gotenberg-go-client/blob/beta-8.6/types.go).
> Head to the [documentation](https://gotenberg.dev/) to learn about all request parameters. For the PaperSize
> method, you can use predefined parameters such as gotenberg.A4, gotenberg.A3 and so on. The full list of
> predefined parameters can be found in [types file](https://github.com/dcaraxes/gotenberg-go-client/v8/blob/master/types.go).
> [!IMPORTANT]
> To use basic authorization, you must run Gotenberg with the --api-enable-basic-auth flag and have GOTENBERG_API_BASIC_AUTH_USERNAME and GOTENBERG_API_BASIC_AUTH_PASSWORD environment variables.
Expand All @@ -60,10 +62,11 @@ func main() {
package main

import (
"context"
"net/http"

"github.com/dcaraxes/gotenberg-go-client"
"github.com/dcaraxes/gotenberg-go-client/document"
"github.com/dcaraxes/gotenberg-go-client/v8"
"github.com/dcaraxes/gotenberg-go-client/v8/document"
)

func main() {
Expand Down Expand Up @@ -94,10 +97,10 @@ func main() {
req.SkipNetworkIdleEvent()

// Store method allows you to store the resulting PDF in a particular destination.
client.Store(req, "path/to/store.pdf")
err := client.Store(context.Background(), req, "path/to/store.pdf")

// If you wish to redirect the response directly to the browser, you may also use:
resp, err := client.Send(req)
resp, err := client.Send(context.Background(), req)
}

```
Expand All @@ -114,10 +117,12 @@ Reading metadata available only for PDF files, but you can write metadata to all
package main

import (
"context"
"encoding/json"
"net/http"

"github.com/dcaraxes/gotenberg-go-client"
"github.com/dcaraxes/gotenberg-go-client/document"
"github.com/dcaraxes/gotenberg-go-client/v8"
"github.com/dcaraxes/gotenberg-go-client/v8/document"
)

func main() {
Expand All @@ -141,7 +146,7 @@ func main() {
md, err := json.Marshal(data)
req.Metadata(md)

resp, err := client.Send(req)
resp, err := client.Send(context.Background(), req)
}
```

Expand All @@ -151,31 +156,32 @@ func main() {
package main

import (
"encoding/json"
"net/http"
"context"
"encoding/json"
"net/http"

"github.com/dcaraxes/gotenberg-go-client"
"github.com/dcaraxes/gotenberg-go-client/document"
"github.com/dcaraxes/gotenberg-go-client/v8"
"github.com/dcaraxes/gotenberg-go-client/v8/document"
)

func main() {
client, err := gotenberg.NewClient("localhost:3000", http.DefaultClient)
client, err := gotenberg.NewClient("localhost:3000", http.DefaultClient)

// Prepare the files required for your conversion.
doc, err := document.FromPath("filename.ext", "/path/to/file")
req := gotenberg.NewReadMetadataRequest(doc)
// Prepare the files required for your conversion.
doc, err := document.FromPath("filename.ext", "/path/to/file")
req := gotenberg.NewReadMetadataRequest(doc)

resp, err := client.Send(req)
resp, err := client.Send(context.Background(), req)

var data = struct {
FooPdf struct {
Author string `json:"Author"`
Copyright string `json:"Copyright"`
} `json:"foo.pdf"`
}
var data = struct {
FooPdf struct {
Author string `json:"Author"`
Copyright string `json:"Copyright"`
} `json:"foo.pdf"`
}

// Decode metadata into a struct.
err = json.NewDecoder(resp.Body).Decode(&data)
// Decode metadata into a struct.
err = json.NewDecoder(resp.Body).Decode(&data)
}

```
Expand All @@ -189,26 +195,27 @@ func main() {
package main

import (
"context"
"net/http"

"github.com/dcaraxes/gotenberg-go-client"
"github.com/dcaraxes/gotenberg-go-client/document"
"github.com/dcaraxes/gotenberg-go-client/v8"
"github.com/dcaraxes/gotenberg-go-client/v8/document"
)

func main() {
c, err := gotenberg.NewClient("localhost:3000", http.DefaultClient)
client, err := gotenberg.NewClient("localhost:3000", http.DefaultClient)

index, err := document.FromPath("index.html", "/path/to/file")

// Create the HTML request and set the image format (optional).
req := gotenberg.NewHTMLRequest(index)
req.Format(gotenberg.JPEG)

resp, err := client.Screenshot(req)
resp, err := client.Screenshot(context.Background(), req)
}

```

---

**For more complete usages, head to the [documentation](https://gotenberg.dev/).**
**For more complete usages, head to the [documentation](https://gotenberg.dev/).**
2 changes: 1 addition & 1 deletion baserequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/json"
"net/http"

"github.com/dcaraxes/gotenberg-go-client/document"
"github.com/dcaraxes/gotenberg-go-client/v8/document"
)

type baseRequester interface {
Expand Down
2 changes: 1 addition & 1 deletion build/tests/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ set -xe
gotenberg --api-enable-basic-auth &
sleep 10
export CGO_ENABLED=1
go test -race -cover -covermode=atomic github.com/dcaraxes/gotenberg-go-client
go test -race -cover -covermode=atomic github.com/dcaraxes/gotenberg-go-client/v8
sleep 10 # allows Gotenberg to remove generated files.
2 changes: 1 addition & 1 deletion chromium.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strconv"
"time"

"github.com/dcaraxes/gotenberg-go-client/document"
"github.com/dcaraxes/gotenberg-go-client/v8/document"
)

type chromiumRequest struct {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
)
2 changes: 1 addition & 1 deletion html.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package gotenberg

import "github.com/dcaraxes/gotenberg-go-client/document"
import "github.com/dcaraxes/gotenberg-go-client/v8/document"

const (
endpointHTMLConvert = "/forms/chromium/convert/html"
Expand Down
4 changes: 2 additions & 2 deletions html_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/dcaraxes/gotenberg-go-client/document"
"github.com/dcaraxes/gotenberg-go-client/test"
"github.com/dcaraxes/gotenberg-go-client/v8/document"
"github.com/dcaraxes/gotenberg-go-client/v8/test"
)

func TestHTML(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion libreoffice.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package gotenberg
import (
"strconv"

"github.com/dcaraxes/gotenberg-go-client/document"
"github.com/dcaraxes/gotenberg-go-client/v8/document"
)

const endpointOfficeConvert = "/forms/libreoffice/convert"
Expand Down
4 changes: 2 additions & 2 deletions libreoffice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/dcaraxes/gotenberg-go-client/document"
"github.com/dcaraxes/gotenberg-go-client/test"
"github.com/dcaraxes/gotenberg-go-client/v8/document"
"github.com/dcaraxes/gotenberg-go-client/v8/test"
)

func TestOffice(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion markdown.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package gotenberg

import "github.com/dcaraxes/gotenberg-go-client/document"
import "github.com/dcaraxes/gotenberg-go-client/v8/document"

const (
endpointMarkdownConvert = "/forms/chromium/convert/markdown"
Expand Down
4 changes: 2 additions & 2 deletions markdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/dcaraxes/gotenberg-go-client/document"
"github.com/dcaraxes/gotenberg-go-client/test"
"github.com/dcaraxes/gotenberg-go-client/v8/document"
"github.com/dcaraxes/gotenberg-go-client/v8/test"
)

func TestMarkdown(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion metadata_reader.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package gotenberg

import "github.com/dcaraxes/gotenberg-go-client/document"
import "github.com/dcaraxes/gotenberg-go-client/v8/document"

type ReadMetadataRequest struct {
pdfs []document.Document
Expand Down
4 changes: 2 additions & 2 deletions metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/dcaraxes/gotenberg-go-client/document"
"github.com/dcaraxes/gotenberg-go-client/test"
"github.com/dcaraxes/gotenberg-go-client/v8/document"
"github.com/dcaraxes/gotenberg-go-client/v8/test"
)

func TestReadWriteMetadata(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion metadata_writer.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package gotenberg

import "github.com/dcaraxes/gotenberg-go-client/document"
import "github.com/dcaraxes/gotenberg-go-client/v8/document"

type WriteMetadataRequest struct {
pdfs []document.Document
Expand Down
2 changes: 1 addition & 1 deletion multipart.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"io"
"mime/multipart"

"github.com/dcaraxes/gotenberg-go-client/document"
"github.com/dcaraxes/gotenberg-go-client/v8/document"
)

func multipartForm(r baseRequester) (body *bytes.Buffer, contentType string, err error) {
Expand Down
2 changes: 1 addition & 1 deletion pdfengines.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package gotenberg
import (
"strconv"

"github.com/dcaraxes/gotenberg-go-client/document"
"github.com/dcaraxes/gotenberg-go-client/v8/document"
)

// MergeRequest facilitates work with PDF files with the Gotenberg API.
Expand Down
4 changes: 2 additions & 2 deletions pdfengines_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/dcaraxes/gotenberg-go-client/document"
"github.com/dcaraxes/gotenberg-go-client/test"
"github.com/dcaraxes/gotenberg-go-client/v8/document"
"github.com/dcaraxes/gotenberg-go-client/v8/test"
)

func TestMerge(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion url.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package gotenberg

import "github.com/dcaraxes/gotenberg-go-client/document"
import "github.com/dcaraxes/gotenberg-go-client/v8/document"

const (
endpointURLConvert = "/forms/chromium/convert/url"
Expand Down
4 changes: 2 additions & 2 deletions url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/dcaraxes/gotenberg-go-client/document"
"github.com/dcaraxes/gotenberg-go-client/test"
"github.com/dcaraxes/gotenberg-go-client/v8/document"
"github.com/dcaraxes/gotenberg-go-client/v8/test"
)

func TestURL(t *testing.T) {
Expand Down

0 comments on commit 7e69df8

Please sign in to comment.