adding filename form field + updating echo package to v4 (#57)

This commit is contained in:
Julien Neuhart
2019-03-26 17:35:38 +01:00
committed by GitHub
parent 8a4a043e9f
commit 871b52a288
21 changed files with 140 additions and 47 deletions

View File

@@ -8,8 +8,8 @@ import (
"os/signal"
"time"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/thecodingmachine/gotenberg/internal/pkg/notify"
"github.com/thecodingmachine/gotenberg/internal/pkg/pm2"
"github.com/thecodingmachine/gotenberg/internal/pkg/printer"
@@ -93,14 +93,17 @@ func print(c echo.Context, p printer.Printer, r *resource) error {
}
filename := fmt.Sprintf("%s.pdf", baseFilename)
fpath := fmt.Sprintf("%s/%s", r.dirPath, filename)
// if no webhook URL given, run conversion
// and directly return the resulting PDF file
// or an error.
if r.webhookURL() == "" {
defer r.removeAll()
// if no webhook URL given, run conversion
// and directly return the resulting PDF file
// or an error.
if err := p.Print(fpath); err != nil {
return err
}
if r.filename() != "" {
filename = r.filename()
}
return c.Attachment(fpath, filename)
}
// as a webhook URL has been given, we