diff --git a/Makefile b/Makefile index e498fc3..3cc6f8b 100644 --- a/Makefile +++ b/Makefile @@ -2,11 +2,11 @@ GOLANG_VERSION=1.23.2 GOTENBERG_VERSION=8.14.1 GOLANGCI_LINT_VERSION=1.61.0 -REPO=runatal/gotenberg-go-client/v8 +REPO=starwalkn/gotenberg-go-client/v8 -# gofmt and goimports all go files. +# gofumpt and goimports all go files. fmt: - go fmt ./... + gofumpt -l -w . go mod tidy # run linters. diff --git a/README.md b/README.md index 5784dbc..30483d3 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ |Gotenberg version | Client version | |:----------------:|:----------------------------------------------------------------------------------------------------------:| -|`8.x` **(actual)**| `8.7.3` **(actual)**
| +|`8.x` **(actual)**| `8.7.4` **(actual)**
| |`7.x` | `<= 8.5.0` | |`6.x` | thecodingmachine/gotenberg-go-client | @@ -18,7 +18,7 @@ To get the latest version of the client: ```zsh -$ go get github.com/runatal/gotenberg-go-client/v8@latest +$ go get github.com/starwalkn/gotenberg-go-client/v8@latest ``` ## Preparing a documents @@ -30,8 +30,8 @@ import ( "net/http" "os" - "github.com/runatal/gotenberg-go-client/v8" - "github.com/runatal/gotenberg-go-client/v8/document" + "github.com/starwalkn/gotenberg-go-client/v8" + "github.com/starwalkn/gotenberg-go-client/v8/document" ) func main() { @@ -65,8 +65,8 @@ import ( "context" "net/http" - "github.com/runatal/gotenberg-go-client/v8" - "github.com/runatal/gotenberg-go-client/v8/document" + "github.com/starwalkn/gotenberg-go-client/v8" + "github.com/starwalkn/gotenberg-go-client/v8/document" ) func main() { @@ -121,8 +121,8 @@ import ( "encoding/json" "net/http" - "github.com/runatal/gotenberg-go-client/v8" - "github.com/runatal/gotenberg-go-client/v8/document" + "github.com/starwalkn/gotenberg-go-client/v8" + "github.com/starwalkn/gotenberg-go-client/v8/document" ) func main() { @@ -160,8 +160,8 @@ import ( "encoding/json" "net/http" - "github.com/runatal/gotenberg-go-client/v8" - "github.com/runatal/gotenberg-go-client/v8/document" + "github.com/starwalkn/gotenberg-go-client/v8" + "github.com/starwalkn/gotenberg-go-client/v8/document" ) func main() { @@ -198,8 +198,8 @@ import ( "context" "net/http" - "github.com/runatal/gotenberg-go-client/v8" - "github.com/runatal/gotenberg-go-client/v8/document" + "github.com/starwalkn/gotenberg-go-client/v8" + "github.com/starwalkn/gotenberg-go-client/v8/document" ) func main() { diff --git a/baserequest.go b/baserequest.go index e505dd9..fae452d 100644 --- a/baserequest.go +++ b/baserequest.go @@ -6,7 +6,7 @@ import ( "fmt" "net/http" - "github.com/runatal/gotenberg-go-client/v8/document" + "github.com/starwalkn/gotenberg-go-client/v8/document" ) type baseRequester interface { diff --git a/build/lint/Dockerfile b/build/lint/Dockerfile index 7e2a4df..2b83a01 100644 --- a/build/lint/Dockerfile +++ b/build/lint/Dockerfile @@ -1,6 +1,6 @@ ARG GOLANG_VERSION -FROM golang:${GOLANG_VERSION}-alpine +FROM golang:${GOLANG_VERSION:-1.23.2}-alpine # |-------------------------------------------------------------------------- # | GolangCI-Lint diff --git a/build/tests/Dockerfile b/build/tests/Dockerfile index 08ef729..305d97c 100644 --- a/build/tests/Dockerfile +++ b/build/tests/Dockerfile @@ -1,9 +1,9 @@ ARG GOLANG_VERSION ARG GOTENBERG_VERSION -FROM golang:${GOLANG_VERSION}-alpine AS golang +FROM golang:${GOLANG_VERSION:-1.23.2}-alpine AS golang -FROM gotenberg/gotenberg:${GOTENBERG_VERSION} +FROM gotenberg/gotenberg:${GOTENBERG_VERSION:-8.14.1} USER root @@ -29,8 +29,8 @@ COPY --from=golang /usr/local/go /usr/local/go RUN export PATH="/usr/local/go/bin:$PATH" &&\ go version -ENV GOPATH /go -ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH +ENV GOPATH=/go +ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH # |-------------------------------------------------------------------------- # | Final touch diff --git a/chromium.go b/chromium.go index b7b82db..f8b9b59 100644 --- a/chromium.go +++ b/chromium.go @@ -6,7 +6,7 @@ import ( "strconv" "time" - "github.com/runatal/gotenberg-go-client/v8/document" + "github.com/starwalkn/gotenberg-go-client/v8/document" ) type chromiumRequest struct { diff --git a/client.go b/client.go index f57ba48..8212364 100644 --- a/client.go +++ b/client.go @@ -18,8 +18,8 @@ var ( errSendRequestFailed = errors.New("request sending failed") ) -// MultipartRequester is a type for sending form fields and form files (documents) to the Gotenberg API. -type MultipartRequester interface { +// multipartRequester is a type for sending form fields and form files (documents) to the Gotenberg API. +type multipartRequester interface { endpoint() string baseRequester @@ -48,11 +48,11 @@ func NewClient(hostname string, httpClient *http.Client) (*Client, error) { } // Send sends a request to the Gotenberg API and returns the response. -func (c *Client) Send(ctx context.Context, req MultipartRequester) (*http.Response, error) { +func (c *Client) Send(ctx context.Context, req multipartRequester) (*http.Response, error) { return c.send(ctx, req) } -func (c *Client) send(ctx context.Context, r MultipartRequester) (*http.Response, error) { +func (c *Client) send(ctx context.Context, r multipartRequester) (*http.Response, error) { req, err := c.createRequest(ctx, r, r.endpoint()) if err != nil { return nil, err @@ -67,11 +67,11 @@ func (c *Client) send(ctx context.Context, r MultipartRequester) (*http.Response } // Store creates the resulting file to given destination. -func (c *Client) Store(ctx context.Context, req MultipartRequester, dest string) error { +func (c *Client) Store(ctx context.Context, req multipartRequester, dest string) error { return c.store(ctx, req, dest) } -func (c *Client) store(ctx context.Context, req MultipartRequester, dest string) error { +func (c *Client) store(ctx context.Context, req multipartRequester, dest string) error { if hasWebhook(req) { return errWebhookNotAllowed } @@ -117,8 +117,8 @@ func writeNewFile(fpath string, in io.Reader) error { return nil } -func (c *Client) createRequest(ctx context.Context, br baseRequester, endpoint string) (*http.Request, error) { - body, contentType, err := multipartForm(br) +func (c *Client) createRequest(ctx context.Context, mr multipartRequester, endpoint string) (*http.Request, error) { + body, contentType, err := multipartForm(mr) if err != nil { return nil, err } @@ -131,7 +131,7 @@ func (c *Client) createRequest(ctx context.Context, br baseRequester, endpoint s } req.Header.Set("Content-Type", contentType) - for key, value := range br.customHeaders() { + for key, value := range mr.customHeaders() { req.Header.Set(string(key), value) } diff --git a/go.mod b/go.mod index ae759c6..6d518cc 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/runatal/gotenberg-go-client/v8 +module github.com/starwalkn/gotenberg-go-client/v8 go 1.23.2 diff --git a/go.sum b/go.sum index 40b0112..713a0b4 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= diff --git a/html.go b/html.go index 3ba7960..e9e61b9 100644 --- a/html.go +++ b/html.go @@ -1,7 +1,7 @@ package gotenberg import ( - "github.com/runatal/gotenberg-go-client/v8/document" + "github.com/starwalkn/gotenberg-go-client/v8/document" ) const ( @@ -54,5 +54,5 @@ func (req *HTMLRequest) Assets(assets ...document.Document) { // Compile-time checks to ensure type implements desired interfaces. var ( - _ = MultipartRequester(new(HTMLRequest)) + _ = multipartRequester(new(HTMLRequest)) ) diff --git a/html_test.go b/html_test.go index b584446..0f44637 100644 --- a/html_test.go +++ b/html_test.go @@ -10,8 +10,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/runatal/gotenberg-go-client/v8/document" - "github.com/runatal/gotenberg-go-client/v8/test" + "github.com/starwalkn/gotenberg-go-client/v8/document" + "github.com/starwalkn/gotenberg-go-client/v8/test" ) func TestHTML(t *testing.T) { diff --git a/libreoffice.go b/libreoffice.go index 2d1d9f0..4fab613 100644 --- a/libreoffice.go +++ b/libreoffice.go @@ -3,30 +3,30 @@ package gotenberg import ( "strconv" - "github.com/runatal/gotenberg-go-client/v8/document" + "github.com/starwalkn/gotenberg-go-client/v8/document" ) const endpointOfficeConvert = "/forms/libreoffice/convert" -// OfficeRequest facilitates LibreOffice documents conversion with the Gotenberg API. -type OfficeRequest struct { +// LibreOfficeRequest facilitates LibreOffice documents conversion with the Gotenberg API. +type LibreOfficeRequest struct { docs []document.Document *baseRequest } -func NewOfficeRequest(docs ...document.Document) *OfficeRequest { - return &OfficeRequest{ +func NewLibreOfficeRequest(docs ...document.Document) *LibreOfficeRequest { + return &LibreOfficeRequest{ docs: docs, baseRequest: newBaseRequest(), } } -func (req *OfficeRequest) endpoint() string { +func (req *LibreOfficeRequest) endpoint() string { return endpointOfficeConvert } -func (req *OfficeRequest) formDocuments() map[string]document.Document { +func (req *LibreOfficeRequest) formDocuments() map[string]document.Document { files := make(map[string]document.Document) for _, doc := range req.docs { files[doc.Filename()] = doc @@ -36,148 +36,148 @@ func (req *OfficeRequest) formDocuments() map[string]document.Document { } // Password sets the password for opening the source file. -func (req *OfficeRequest) Password(password string) { +func (req *LibreOfficeRequest) Password(password string) { req.fields[fieldOfficePassword] = password } // Landscape sets the paper orientation to landscape. -func (req *OfficeRequest) Landscape() { +func (req *LibreOfficeRequest) Landscape() { req.fields[fieldOfficeLandscape] = strconv.FormatBool(true) } // NativePageRanges sets the page ranges to print, e.g., "1-4". Empty means all pages. -func (req *OfficeRequest) NativePageRanges(ranges string) { +func (req *LibreOfficeRequest) NativePageRanges(ranges string) { req.fields[fieldOfficeNativePageRanges] = ranges } // ExportFormFields specifies whether form fields are exported as widgets // or only their fixed print representation is exported. -func (req *OfficeRequest) ExportFormFields(export bool) { +func (req *LibreOfficeRequest) ExportFormFields(export bool) { req.fields[fieldOfficeExportFormFields] = strconv.FormatBool(export) } // AllowDuplicateFieldNames specifies whether multiple form fields exported are allowed to have the same field name. -func (req *OfficeRequest) AllowDuplicateFieldNames() { +func (req *LibreOfficeRequest) AllowDuplicateFieldNames() { req.fields[fieldOfficeAllowDuplicateFieldNames] = strconv.FormatBool(true) } // ExportBookmarks specifies if bookmarks are exported to PDF. -func (req *OfficeRequest) ExportBookmarks(export bool) { +func (req *LibreOfficeRequest) ExportBookmarks(export bool) { req.fields[fieldOfficeExportBookmarks] = strconv.FormatBool(export) } // ExportBookmarksToPdfDestination specifies that the bookmarks contained // in the source LibreOffice file should be exported to the PDF file as Named Destination. -func (req *OfficeRequest) ExportBookmarksToPdfDestination() { +func (req *LibreOfficeRequest) ExportBookmarksToPdfDestination() { req.fields[fieldOfficeExportBookmarksToPdfDestination] = strconv.FormatBool(true) } // ExportPlaceholders exports the placeholders fields visual markings only. The exported placeholder is ineffective. -func (req *OfficeRequest) ExportPlaceholders() { +func (req *LibreOfficeRequest) ExportPlaceholders() { req.fields[fieldOfficeExportPlaceholders] = strconv.FormatBool(true) } // ExportNotes specifies if notes are exported to PDF. -func (req *OfficeRequest) ExportNotes() { +func (req *LibreOfficeRequest) ExportNotes() { req.fields[fieldOfficeExportNotes] = strconv.FormatBool(true) } // ExportNotesPages specifies if notes pages are exported to PDF. Notes pages are available in Impress documents only. -func (req *OfficeRequest) ExportNotesPages() { +func (req *LibreOfficeRequest) ExportNotesPages() { req.fields[fieldOfficeExportNotesPages] = strconv.FormatBool(true) } // ExportOnlyNotesPages specifies, if the form field exportNotesPages // is set to true, if only notes pages are exported to PDF. -func (req *OfficeRequest) ExportOnlyNotesPages() { +func (req *LibreOfficeRequest) ExportOnlyNotesPages() { req.fields[fieldOfficeExportOnlyNotesPages] = strconv.FormatBool(true) } // ExportNotesInMargin specifies if notes in margin are exported to PDF. -func (req *OfficeRequest) ExportNotesInMargin() { +func (req *LibreOfficeRequest) ExportNotesInMargin() { req.fields[fieldOfficeExportNotesInMargin] = strconv.FormatBool(true) } // ConvertOooTargetToPdfTarget specifies that the target documents with .od[tpgs] extension, // will have that extension changed to .pdf when the link is exported to PDF. The source document remains untouched. -func (req *OfficeRequest) ConvertOooTargetToPdfTarget() { +func (req *LibreOfficeRequest) ConvertOooTargetToPdfTarget() { req.fields[fieldOfficeConvertOooTargetToPdfTarget] = strconv.FormatBool(true) } // ExportLinksRelativeFsys specifies that the file system related hyperlinks (file:// protocol) present // in the document will be exported as relative to the source document location. -func (req *OfficeRequest) ExportLinksRelativeFsys() { +func (req *LibreOfficeRequest) ExportLinksRelativeFsys() { req.fields[fieldOfficeExportLinksRelativeFsys] = strconv.FormatBool(true) } // ExportHiddenSlides exports, for LibreOffice Impress, slides that are not included in slide shows. -func (req *OfficeRequest) ExportHiddenSlides() { +func (req *LibreOfficeRequest) ExportHiddenSlides() { req.fields[fieldOfficeExportHiddenSlides] = strconv.FormatBool(true) } // SkipEmptyPages Specifies that automatically inserted empty pages are suppressed. // This option is active only if storing Writer documents. -func (req *OfficeRequest) SkipEmptyPages() { +func (req *LibreOfficeRequest) SkipEmptyPages() { req.fields[fieldOfficeSkipEmptyPages] = strconv.FormatBool(true) } // AddOriginalDocumentAsStream specifies that a stream is inserted to the PDF file // which contains the original document for archiving purposes. -func (req *OfficeRequest) AddOriginalDocumentAsStream() { +func (req *LibreOfficeRequest) AddOriginalDocumentAsStream() { req.fields[fieldOfficeAddOriginalDocumentAsStream] = strconv.FormatBool(true) } // SinglePageSheets ignores each sheet’s paper size, print ranges and shown/hidden // status and puts every sheet (even hidden sheets) on exactly one page. -func (req *OfficeRequest) SinglePageSheets() { +func (req *LibreOfficeRequest) SinglePageSheets() { req.fields[fieldOfficeSinglePageSheets] = strconv.FormatBool(true) } // LosslessImageCompression specifies if images are exported to PDF using a lossless compression // format like PNG or compressed using the JPEG format. -func (req *OfficeRequest) LosslessImageCompression() { +func (req *LibreOfficeRequest) LosslessImageCompression() { req.fields[fieldOfficeLosslessImageCompression] = strconv.FormatBool(true) } // Quality specifies the quality of the JPG export. A higher value produces a higher-quality image and a larger file. // Between 1 and 100. -func (req *OfficeRequest) Quality(quality int) { +func (req *LibreOfficeRequest) Quality(quality int) { req.fields[fieldOfficeQuality] = strconv.Itoa(quality) } // ReduceImageResolution Specifies if the resolution of each image is reduced to the resolution specified by the // form field maxImageResolution. -func (req *OfficeRequest) ReduceImageResolution() { +func (req *LibreOfficeRequest) ReduceImageResolution() { req.fields[fieldOfficeReduceImageResolution] = strconv.FormatBool(true) } // MaxImageResolution If the form field reduceImageResolution is set to true, tells if all images will be reduced // to the given value in DPI. Possible values are: 75, 150, 300, 600 and 1200. -func (req *OfficeRequest) MaxImageResolution(res int) { +func (req *LibreOfficeRequest) MaxImageResolution(res int) { req.fields[fieldOfficeMaxImageResolution] = strconv.Itoa(res) } // PdfA sets the PDF/A format of the resulting PDF. -func (req *OfficeRequest) PdfA(pdfa PdfAFormat) { +func (req *LibreOfficeRequest) PdfA(pdfa PdfAFormat) { req.fields[fieldOfficePdfA] = string(pdfa) } // PdfUA enables PDF for Universal Access for optimal accessibility. -func (req *OfficeRequest) PdfUA() { +func (req *LibreOfficeRequest) PdfUA() { req.fields[fieldOfficePdfUa] = strconv.FormatBool(true) } // Metadata sets the metadata to write. -func (req *OfficeRequest) Metadata(md []byte) { +func (req *LibreOfficeRequest) Metadata(md []byte) { req.fields[fieldMetadata] = string(md) } // Merge merges the resulting PDFs. -func (req *OfficeRequest) Merge() { +func (req *LibreOfficeRequest) Merge() { req.fields[fieldOfficeMerge] = strconv.FormatBool(true) } // Compile-time checks to ensure type implements desired interfaces. var ( - _ = MultipartRequester(new(OfficeRequest)) + _ = multipartRequester(new(LibreOfficeRequest)) ) diff --git a/libreoffice_test.go b/libreoffice_test.go index 19f15fe..121c4b0 100644 --- a/libreoffice_test.go +++ b/libreoffice_test.go @@ -10,18 +10,18 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/runatal/gotenberg-go-client/v8/document" - "github.com/runatal/gotenberg-go-client/v8/test" + "github.com/starwalkn/gotenberg-go-client/v8/document" + "github.com/starwalkn/gotenberg-go-client/v8/test" ) -func TestOffice(t *testing.T) { +func TestLibreOffice(t *testing.T) { c, err := NewClient("http://localhost:3000", http.DefaultClient) require.NoError(t, err) - doc, err := document.FromPath("document.docx", test.OfficeTestFilePath(t, "document.docx")) + doc, err := document.FromPath("document.docx", test.LibreOfficeTestFilePath(t, "document.docx")) require.NoError(t, err) - req := NewOfficeRequest(doc) - req.Trace("testOffice") + req := NewLibreOfficeRequest(doc) + req.Trace("testLibreOffice") req.UseBasicAuth("foo", "bar") req.OutputFilename("foo.pdf") dirPath := t.TempDir() @@ -37,14 +37,14 @@ func TestOffice(t *testing.T) { assert.False(t, isPDFA) } -func TestOfficePageRanges(t *testing.T) { +func TestLibreOfficePageRanges(t *testing.T) { c, err := NewClient("http://localhost:3000", http.DefaultClient) require.NoError(t, err) - doc, err := document.FromPath("document.docx", test.OfficeTestFilePath(t, "document.docx")) + doc, err := document.FromPath("document.docx", test.LibreOfficeTestFilePath(t, "document.docx")) require.NoError(t, err) - req := NewOfficeRequest(doc) - req.Trace("testOfficePageRanges") + req := NewLibreOfficeRequest(doc) + req.Trace("testLibreOfficePageRanges") req.UseBasicAuth("foo", "bar") req.NativePageRanges("1-1") resp, err := c.Send(context.Background(), req) @@ -52,14 +52,14 @@ func TestOfficePageRanges(t *testing.T) { assert.Equal(t, 200, resp.StatusCode) } -func TestOfficeLosslessCompression(t *testing.T) { +func TestLibreOfficeLosslessCompression(t *testing.T) { c, err := NewClient("http://localhost:3000", http.DefaultClient) require.NoError(t, err) - doc, err := document.FromPath("document.docx", test.OfficeTestFilePath(t, "document.docx")) + doc, err := document.FromPath("document.docx", test.LibreOfficeTestFilePath(t, "document.docx")) require.NoError(t, err) - req := NewOfficeRequest(doc) - req.Trace("testOfficeLosslessCompression") + req := NewLibreOfficeRequest(doc) + req.Trace("testLibreOfficeLosslessCompression") req.UseBasicAuth("foo", "bar") req.OutputFilename("foo.pdf") req.LosslessImageCompression() @@ -73,14 +73,14 @@ func TestOfficeLosslessCompression(t *testing.T) { assert.True(t, isPDF) } -func TestOfficeCompression(t *testing.T) { +func TestLibreOfficeCompression(t *testing.T) { c, err := NewClient("http://localhost:3000", http.DefaultClient) require.NoError(t, err) - doc, err := document.FromPath("document.docx", test.OfficeTestFilePath(t, "document.docx")) + doc, err := document.FromPath("document.docx", test.LibreOfficeTestFilePath(t, "document.docx")) require.NoError(t, err) - req := NewOfficeRequest(doc) - req.Trace("testOfficeCompression") + req := NewLibreOfficeRequest(doc) + req.Trace("testLibreOfficeCompression") req.UseBasicAuth("foo", "bar") req.OutputFilename("foo.pdf") req.Quality(1) @@ -96,16 +96,16 @@ func TestOfficeCompression(t *testing.T) { assert.True(t, isPDF) } -func TestOfficeMultipleWithoutMerge(t *testing.T) { +func TestLibreOfficeMultipleWithoutMerge(t *testing.T) { c, err := NewClient("http://localhost:3000", http.DefaultClient) require.NoError(t, err) - doc1, err := document.FromPath("document1.docx", test.OfficeTestFilePath(t, "document.docx")) + doc1, err := document.FromPath("document1.docx", test.LibreOfficeTestFilePath(t, "document.docx")) require.NoError(t, err) - doc2, err := document.FromPath("document2.docx", test.OfficeTestFilePath(t, "document.docx")) + doc2, err := document.FromPath("document2.docx", test.LibreOfficeTestFilePath(t, "document.docx")) require.NoError(t, err) - req := NewOfficeRequest(doc1, doc2) - req.Trace("testOfficeMultipleWithoutMerge") + req := NewLibreOfficeRequest(doc1, doc2) + req.Trace("testLibreOfficeMultipleWithoutMerge") req.UseBasicAuth("foo", "bar") req.OutputFilename("foo.zip") dirPath := t.TempDir() @@ -135,16 +135,16 @@ func TestOfficeMultipleWithoutMerge(t *testing.T) { require.NoError(t, err) } -func TestOfficeMultipleWithMerge(t *testing.T) { +func TestLibreOfficeMultipleWithMerge(t *testing.T) { c, err := NewClient("http://localhost:3000", http.DefaultClient) require.NoError(t, err) - doc1, err := document.FromPath("document1.docx", test.OfficeTestFilePath(t, "document.docx")) + doc1, err := document.FromPath("document1.docx", test.LibreOfficeTestFilePath(t, "document.docx")) require.NoError(t, err) - doc2, err := document.FromPath("document2.docx", test.OfficeTestFilePath(t, "document.docx")) + doc2, err := document.FromPath("document2.docx", test.LibreOfficeTestFilePath(t, "document.docx")) require.NoError(t, err) - req := NewOfficeRequest(doc1, doc2) - req.Trace("testOfficeMultipleWithMerge") + req := NewLibreOfficeRequest(doc1, doc2) + req.Trace("testLibreOfficeMultipleWithMerge") req.UseBasicAuth("foo", "bar") req.OutputFilename("foo.pdf") req.Merge() @@ -158,14 +158,14 @@ func TestOfficeMultipleWithMerge(t *testing.T) { assert.True(t, isPDF) } -func TestOfficePdfA(t *testing.T) { +func TestLibreOfficePdfA(t *testing.T) { c, err := NewClient("http://localhost:3000", http.DefaultClient) require.NoError(t, err) - doc, err := document.FromPath("document.docx", test.OfficeTestFilePath(t, "document.docx")) + doc, err := document.FromPath("document.docx", test.LibreOfficeTestFilePath(t, "document.docx")) require.NoError(t, err) - req := NewOfficeRequest(doc) - req.Trace("testOfficePdfA") + req := NewLibreOfficeRequest(doc) + req.Trace("testLibreOfficePdfA") req.UseBasicAuth("foo", "bar") req.OutputFilename("foo.pdf") req.PdfA(PdfA3b) @@ -179,14 +179,14 @@ func TestOfficePdfA(t *testing.T) { assert.True(t, isPDFA) } -func TestOfficePdfUA(t *testing.T) { +func TestLibreOfficePdfUA(t *testing.T) { c, err := NewClient("http://localhost:3000", http.DefaultClient) require.NoError(t, err) - doc, err := document.FromPath("document.docx", test.OfficeTestFilePath(t, "document.docx")) + doc, err := document.FromPath("document.docx", test.LibreOfficeTestFilePath(t, "document.docx")) require.NoError(t, err) - req := NewOfficeRequest(doc) - req.Trace("testOfficePdfUA") + req := NewLibreOfficeRequest(doc) + req.Trace("testLibreOfficePdfUA") req.UseBasicAuth("foo", "bar") req.OutputFilename("foo.pdf") req.PdfUA() diff --git a/markdown.go b/markdown.go index 53e776e..d057970 100644 --- a/markdown.go +++ b/markdown.go @@ -1,6 +1,6 @@ package gotenberg -import "github.com/runatal/gotenberg-go-client/v8/document" +import "github.com/starwalkn/gotenberg-go-client/v8/document" const ( endpointMarkdownConvert = "/forms/chromium/convert/markdown" @@ -54,5 +54,5 @@ func (req *MarkdownRequest) Assets(assets ...document.Document) { // Compile-time checks to ensure type implements desired interfaces. var ( - _ = MultipartRequester(new(MarkdownRequest)) + _ = multipartRequester(new(MarkdownRequest)) ) diff --git a/markdown_test.go b/markdown_test.go index 458dbae..fdec769 100644 --- a/markdown_test.go +++ b/markdown_test.go @@ -10,8 +10,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/runatal/gotenberg-go-client/v8/document" - "github.com/runatal/gotenberg-go-client/v8/test" + "github.com/starwalkn/gotenberg-go-client/v8/document" + "github.com/starwalkn/gotenberg-go-client/v8/test" ) func TestMarkdown(t *testing.T) { diff --git a/metadata_reader.go b/metadata_reader.go index f131533..951b287 100644 --- a/metadata_reader.go +++ b/metadata_reader.go @@ -1,6 +1,8 @@ package gotenberg -import "github.com/runatal/gotenberg-go-client/v8/document" +import "github.com/starwalkn/gotenberg-go-client/v8/document" + +const endpointMetadataRead = "/forms/pdfengines/metadata/read" type ReadMetadataRequest struct { pdfs []document.Document @@ -16,7 +18,7 @@ func NewReadMetadataRequest(pdfs ...document.Document) *ReadMetadataRequest { } func (rmd *ReadMetadataRequest) endpoint() string { - return "/forms/pdfengines/metadata/read" + return endpointMetadataRead } func (rmd *ReadMetadataRequest) formDocuments() map[string]document.Document { @@ -31,5 +33,5 @@ func (rmd *ReadMetadataRequest) formDocuments() map[string]document.Document { // Compile-time checks to ensure type implements desired interfaces. var ( - _ = MultipartRequester(new(ReadMetadataRequest)) + _ = multipartRequester(new(ReadMetadataRequest)) ) diff --git a/metadata_test.go b/metadata_test.go index dd5b676..9254653 100644 --- a/metadata_test.go +++ b/metadata_test.go @@ -10,8 +10,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/runatal/gotenberg-go-client/v8/document" - "github.com/runatal/gotenberg-go-client/v8/test" + "github.com/starwalkn/gotenberg-go-client/v8/document" + "github.com/starwalkn/gotenberg-go-client/v8/test" ) func TestReadWriteMetadata(t *testing.T) { diff --git a/metadata_writer.go b/metadata_writer.go index 62d1b32..a54e645 100644 --- a/metadata_writer.go +++ b/metadata_writer.go @@ -1,6 +1,8 @@ package gotenberg -import "github.com/runatal/gotenberg-go-client/v8/document" +import "github.com/starwalkn/gotenberg-go-client/v8/document" + +const endpointMetadataWrite = "/forms/pdfengines/metadata/write" type WriteMetadataRequest struct { pdfs []document.Document @@ -16,7 +18,7 @@ func NewWriteMetadataRequest(pdfs ...document.Document) *WriteMetadataRequest { } func (wmd *WriteMetadataRequest) endpoint() string { - return "/forms/pdfengines/metadata/write" + return endpointMetadataWrite } func (wmd *WriteMetadataRequest) formDocuments() map[string]document.Document { @@ -35,5 +37,5 @@ func (wmd *WriteMetadataRequest) Metadata(md []byte) { // Compile-time checks to ensure type implements desired interfaces. var ( - _ = MultipartRequester(new(WriteMetadataRequest)) + _ = multipartRequester(new(WriteMetadataRequest)) ) diff --git a/multipart.go b/multipart.go index 17fe9f6..6a4bf7f 100644 --- a/multipart.go +++ b/multipart.go @@ -6,10 +6,10 @@ import ( "io" "mime/multipart" - "github.com/runatal/gotenberg-go-client/v8/document" + "github.com/starwalkn/gotenberg-go-client/v8/document" ) -func multipartForm(r baseRequester) (body *bytes.Buffer, contentType string, err error) { +func multipartForm(mr multipartRequester) (body *bytes.Buffer, contentType string, err error) { body = &bytes.Buffer{} writer := multipart.NewWriter(body) @@ -19,11 +19,11 @@ func multipartForm(r baseRequester) (body *bytes.Buffer, contentType string, err } }() - if err = addDocuments(writer, r.formDocuments()); err != nil { + if err = addDocuments(writer, mr.formDocuments()); err != nil { return nil, "", err } - if err = addFormFields(writer, r.formFields()); err != nil { + if err = addFormFields(writer, mr.formFields()); err != nil { return nil, "", err } diff --git a/pdfengines.go b/pdfengines.go index 972f0a2..f5f1bef 100644 --- a/pdfengines.go +++ b/pdfengines.go @@ -3,9 +3,11 @@ package gotenberg import ( "strconv" - "github.com/runatal/gotenberg-go-client/v8/document" + "github.com/starwalkn/gotenberg-go-client/v8/document" ) +const endpointMerge = "/forms/pdfengines/merge" + // MergeRequest facilitates work with PDF files with the Gotenberg API. type MergeRequest struct { pdfs []document.Document @@ -18,7 +20,7 @@ func NewMergeRequest(pdfs ...document.Document) *MergeRequest { } func (req *MergeRequest) endpoint() string { - return "/forms/pdfengines/merge" + return endpointMerge } func (req *MergeRequest) formDocuments() map[string]document.Document { @@ -48,5 +50,5 @@ func (req *MergeRequest) Metadata(md []byte) { // Compile-time checks to ensure type implements desired interfaces. var ( - _ = MultipartRequester(new(MergeRequest)) + _ = multipartRequester(new(MergeRequest)) ) diff --git a/pdfengines_test.go b/pdfengines_test.go index 471eaa0..f8ea957 100644 --- a/pdfengines_test.go +++ b/pdfengines_test.go @@ -9,8 +9,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/runatal/gotenberg-go-client/v8/document" - "github.com/runatal/gotenberg-go-client/v8/test" + "github.com/starwalkn/gotenberg-go-client/v8/document" + "github.com/starwalkn/gotenberg-go-client/v8/test" ) func TestMerge(t *testing.T) { diff --git a/screenshot.go b/screenshot.go index f838f92..b9f080a 100644 --- a/screenshot.go +++ b/screenshot.go @@ -6,17 +6,17 @@ import ( "net/http" ) -type ScreenshotRequester interface { +type screenshotRequester interface { screenshotEndpoint() string - baseRequester + multipartRequester } -func (c *Client) Screenshot(ctx context.Context, scr ScreenshotRequester) (*http.Response, error) { +func (c *Client) Screenshot(ctx context.Context, scr screenshotRequester) (*http.Response, error) { return c.screenshot(ctx, scr) } -func (c *Client) screenshot(ctx context.Context, scr ScreenshotRequester) (*http.Response, error) { +func (c *Client) screenshot(ctx context.Context, scr screenshotRequester) (*http.Response, error) { req, err := c.createRequest(ctx, scr, scr.screenshotEndpoint()) if err != nil { return nil, err @@ -30,11 +30,11 @@ func (c *Client) screenshot(ctx context.Context, scr ScreenshotRequester) (*http return resp, nil } -func (c *Client) StoreScreenshot(ctx context.Context, req ScreenshotRequester, dest string) error { +func (c *Client) StoreScreenshot(ctx context.Context, req screenshotRequester, dest string) error { return c.storeScreenshot(ctx, req, dest) } -func (c *Client) storeScreenshot(ctx context.Context, scr ScreenshotRequester, dest string) error { +func (c *Client) storeScreenshot(ctx context.Context, scr screenshotRequester, dest string) error { if hasWebhook(scr) { return errWebhookNotAllowed } diff --git a/test/testdata/office/document.docx b/test/testdata/libreoffice/document.docx similarity index 100% rename from test/testdata/office/document.docx rename to test/testdata/libreoffice/document.docx diff --git a/test/testdata/office/document.rtf b/test/testdata/libreoffice/document.rtf similarity index 100% rename from test/testdata/office/document.rtf rename to test/testdata/libreoffice/document.rtf diff --git a/test/testdata/office/document.txt b/test/testdata/libreoffice/document.txt similarity index 100% rename from test/testdata/office/document.txt rename to test/testdata/libreoffice/document.txt diff --git a/test/testfunc.go b/test/testfunc.go index 995a822..69c5756 100644 --- a/test/testfunc.go +++ b/test/testfunc.go @@ -25,9 +25,9 @@ func MarkdownTestFilePath(t *testing.T, filename string) string { return abs(t, "markdown", filename) } -// OfficeTestFilePath returns the absolute file path of a file in "office" folder in test/testdata. -func OfficeTestFilePath(t *testing.T, filename string) string { - return abs(t, "office", filename) +// LibreOfficeTestFilePath returns the absolute file path of a file in "libreoffice" folder in test/testdata. +func LibreOfficeTestFilePath(t *testing.T, filename string) string { + return abs(t, "libreoffice", filename) } // PDFTestFilePath returns the absolute file path of a file in "pdf" folder in test/testdata. diff --git a/url.go b/url.go index 75cd864..64ea34d 100644 --- a/url.go +++ b/url.go @@ -1,6 +1,6 @@ package gotenberg -import "github.com/runatal/gotenberg-go-client/v8/document" +import "github.com/starwalkn/gotenberg-go-client/v8/document" const ( endpointURLConvert = "/forms/chromium/convert/url" @@ -42,5 +42,5 @@ func (req *URLRequest) formDocuments() map[string]document.Document { // Compile-time checks to ensure type implements desired interfaces. var ( - _ = MultipartRequester(new(URLRequest)) + _ = multipartRequester(new(URLRequest)) ) diff --git a/url_test.go b/url_test.go index 5468823..ce7ae9b 100644 --- a/url_test.go +++ b/url_test.go @@ -10,8 +10,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/runatal/gotenberg-go-client/v8/document" - "github.com/runatal/gotenberg-go-client/v8/test" + "github.com/starwalkn/gotenberg-go-client/v8/document" + "github.com/starwalkn/gotenberg-go-client/v8/test" ) func TestURL(t *testing.T) {