Skip to content

Commit

Permalink
8.7.2 (#27)
Browse files Browse the repository at this point in the history
* feat: fix FailOnResourceHTTPStatusCodes method

* chore: rename MainRequester interface to MultipartRequester

---------

Co-authored-by: Alexander Pikeev <[email protected]>
  • Loading branch information
starwalkn and Alexander Pikeev authored Dec 12, 2024
1 parent 2aa4bb0 commit fc612f3
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions chromium.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (req *chromiumRequest) FailOnResourceHTTPStatusCodes(statusCodes []int) err
return fmt.Errorf("marshal HTTP status codes to JSON: %w", err)
}

req.fields[fieldChromiumFailOnHTTPStatusCodes] = string(marshaledStatusCodes)
req.fields[fieldChromiumFailOnResourceHTTPStatusCodes] = string(marshaledStatusCodes)

return nil
}
Expand Down Expand Up @@ -237,4 +237,4 @@ func (req *chromiumRequest) ScreenshotOptimizeForSpeed() {
// Format sets the image compression format, either PNG, JPEG or WEBP. Default is PNG.
func (req *chromiumRequest) Format(format ImageFormat) {
req.fields[fieldScreenshotFormat] = string(format)
}
}
12 changes: 6 additions & 6 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ var (
errSendRequestFailed = errors.New("request sending failed")
)

// MainRequester is a type for sending form fields and form files (documents) to the Gotenberg API.
type MainRequester interface {
// MultipartRequester is a type for sending form fields and form files (documents) to the Gotenberg API.
type MultipartRequester interface {
endpoint() string

baseRequester
Expand Down Expand Up @@ -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 MainRequester) (*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 MainRequester) (*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
Expand All @@ -67,11 +67,11 @@ func (c *Client) send(ctx context.Context, r MainRequester) (*http.Response, err
}

// Store creates the resulting file to given destination.
func (c *Client) Store(ctx context.Context, req MainRequester, 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 MainRequester, dest string) error {
func (c *Client) store(ctx context.Context, req MultipartRequester, dest string) error {
if hasWebhook(req) {
return errWebhookNotAllowed
}
Expand Down
2 changes: 1 addition & 1 deletion html.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ func (req *HTMLRequest) Assets(assets ...document.Document) {

// Compile-time checks to ensure type implements desired interfaces.
var (
_ = MainRequester(new(HTMLRequest))
_ = MultipartRequester(new(HTMLRequest))
)
2 changes: 1 addition & 1 deletion libreoffice.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,5 @@ func (req *OfficeRequest) Merge() {

// Compile-time checks to ensure type implements desired interfaces.
var (
_ = MainRequester(new(OfficeRequest))
_ = MultipartRequester(new(OfficeRequest))
)
2 changes: 1 addition & 1 deletion markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ func (req *MarkdownRequest) Assets(assets ...document.Document) {

// Compile-time checks to ensure type implements desired interfaces.
var (
_ = MainRequester(new(MarkdownRequest))
_ = MultipartRequester(new(MarkdownRequest))
)
2 changes: 1 addition & 1 deletion metadata_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ func (rmd *ReadMetadataRequest) formDocuments() map[string]document.Document {

// Compile-time checks to ensure type implements desired interfaces.
var (
_ = MainRequester(new(ReadMetadataRequest))
_ = MultipartRequester(new(ReadMetadataRequest))
)
4 changes: 2 additions & 2 deletions metadata_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ func (wmd *WriteMetadataRequest) Metadata(md []byte) {

// Compile-time checks to ensure type implements desired interfaces.
var (
_ = MainRequester(new(WriteMetadataRequest))
)
_ = MultipartRequester(new(WriteMetadataRequest))
)
2 changes: 1 addition & 1 deletion pdfengines.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ func (req *MergeRequest) Metadata(md []byte) {

// Compile-time checks to ensure type implements desired interfaces.
var (
_ = MainRequester(new(MergeRequest))
_ = MultipartRequester(new(MergeRequest))
)
2 changes: 1 addition & 1 deletion url.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ func (req *URLRequest) formDocuments() map[string]document.Document {

// Compile-time checks to ensure type implements desired interfaces.
var (
_ = MainRequester(new(URLRequest))
_ = MultipartRequester(new(URLRequest))
)

0 comments on commit fc612f3

Please sign in to comment.