rolling back to golangci-lint 1.20.1 + moving normize filename to resource & tests with a file with special chars in its name + webhookurl custom headers done + preparing remote url custom headers

This commit is contained in:
Julien Neuhart
2019-12-05 18:16:02 +01:00
parent 5140e4ec9a
commit 782f6ac27e
10 changed files with 191 additions and 26 deletions

View File

@@ -12,7 +12,6 @@ import (
"github.com/labstack/echo/v4"
"github.com/thecodingmachine/gotenberg/internal/app/xhttp/pkg/resource"
"github.com/thecodingmachine/gotenberg/internal/pkg/conf"
"github.com/thecodingmachine/gotenberg/internal/pkg/normalize"
"github.com/thecodingmachine/gotenberg/internal/pkg/xerror"
"github.com/thecodingmachine/gotenberg/internal/pkg/xlog"
)
@@ -79,6 +78,10 @@ func (ctx *Context) WithResource(directoryName string) error {
if err != nil {
return r, err
}
// retrieve custom headers from request.
for name, value := range ctx.Request().Header {
r.WithCustomHeader(name, value)
}
// retrieve form values from request.
for _, key := range resource.ArgKeys() {
r.WithArg(key, ctx.FormValue(string(key)))
@@ -103,11 +106,7 @@ func (ctx *Context) WithResource(directoryName string) error {
return r, err
}
defer in.Close() // nolint: errcheck
filename, err := normalize.String(fh.Filename)
if err != nil {
return r, err
}
if err := r.WithFile(filename, in); err != nil {
if err := r.WithFile(fh.Filename, in); err != nil {
return r, err
}
}