rolling back from previous implementation, now using master version of unoconv

This commit is contained in:
Julien Neuhart
2019-09-26 18:07:43 +02:00
parent 88f74d5e9c
commit 24e6a86bf5
47 changed files with 346 additions and 3034 deletions

View File

@@ -1,7 +1,6 @@
package xhttp
import (
timeoutContext "context"
"fmt"
"net/http"
"os"
@@ -9,10 +8,8 @@ import (
"github.com/labstack/echo/v4"
"github.com/thecodingmachine/gotenberg/internal/app/xhttp/pkg/context"
"github.com/thecodingmachine/gotenberg/internal/app/xhttp/pkg/resource"
"github.com/thecodingmachine/gotenberg/internal/pkg/pm2"
"github.com/thecodingmachine/gotenberg/internal/pkg/xcontext"
"github.com/thecodingmachine/gotenberg/internal/pkg/printer"
"github.com/thecodingmachine/gotenberg/internal/pkg/xerror"
"github.com/thecodingmachine/gotenberg/internal/pkg/xlog"
"github.com/thecodingmachine/gotenberg/internal/pkg/xrand"
"github.com/thecodingmachine/gotenberg/internal/pkg/xtime"
)
@@ -33,23 +30,6 @@ func pingHandler(c echo.Context) error {
ctx := context.MustCastFromEchoContext(c)
logger := ctx.XLogger()
logger.DebugOp(op, "handling ping request...")
resolver := func() error {
if err := ctx.ProcessesHealthcheck(); err != nil {
return err
}
if logger.Level() != xlog.DebugLevel {
return nil
}
// TODO
list, err := pm2.List()
if err != nil {
return err
}
return ctx.JSON(http.StatusOK, list)
}
if err := resolver(); err != nil {
return xerror.New(op, err)
}
return nil
}
@@ -61,21 +41,17 @@ func mergeHandler(c echo.Context) error {
ctx := context.MustCastFromEchoContext(c)
logger := ctx.XLogger()
logger.DebugOp(op, "handling merge request...")
config := ctx.Config()
r := ctx.MustResource()
timeout, err := resource.WaitTimeoutAndWaitDelayArg(r, config)
opts, err := mergePrinterOptions(r, ctx.Config())
if err != nil {
return err
return xerror.New(op, err)
}
fpaths, err := r.Fpaths(".pdf")
if err != nil {
return err
}
prinry := ctx.Prinery()
printFunc := func(ctx timeoutContext.Context, logger xlog.Logger, dest string) error {
return prinry.Merge(ctx, logger, dest, fpaths)
}
return convert(ctx, timeout, printFunc)
p := printer.NewMergePrinter(logger, fpaths, opts)
return convert(ctx, p)
}
if err := resolver(); err != nil {
return xerror.New(op, err)
@@ -91,13 +67,8 @@ func htmlHandler(c echo.Context) error {
ctx := context.MustCastFromEchoContext(c)
logger := ctx.XLogger()
logger.DebugOp(op, "handling HTML request...")
config := ctx.Config()
r := ctx.MustResource()
timeout, err := resource.WaitTimeoutAndWaitDelayArg(r, config)
if err != nil {
return err
}
opts, err := chromePrintOptions(r, config)
opts, err := chromePrinterOptions(r, ctx.Config())
if err != nil {
return err
}
@@ -105,11 +76,8 @@ func htmlHandler(c echo.Context) error {
if err != nil {
return err
}
prinry := ctx.Prinery()
printFunc := func(ctx timeoutContext.Context, logger xlog.Logger, dest string) error {
return prinry.HTML(ctx, logger, dest, fpath, opts)
}
return convert(ctx, timeout, printFunc)
p := printer.NewHTMLPrinter(logger, fpath, opts)
return convert(ctx, p)
}
if err := resolver(); err != nil {
return xerror.New(op, err)
@@ -125,13 +93,8 @@ func urlHandler(c echo.Context) error {
ctx := context.MustCastFromEchoContext(c)
logger := ctx.XLogger()
logger.DebugOp(op, "handling URL request...")
config := ctx.Config()
r := ctx.MustResource()
timeout, err := resource.WaitTimeoutAndWaitDelayArg(r, config)
if err != nil {
return err
}
opts, err := chromePrintOptions(r, config)
opts, err := chromePrinterOptions(r, ctx.Config())
if err != nil {
return err
}
@@ -146,11 +109,8 @@ func urlHandler(c echo.Context) error {
if err != nil {
return err
}
prinry := ctx.Prinery()
printFunc := func(ctx timeoutContext.Context, logger xlog.Logger, dest string) error {
return prinry.URL(ctx, logger, dest, remoteURL, opts)
}
return convert(ctx, timeout, printFunc)
p := printer.NewURLPrinter(logger, remoteURL, opts)
return convert(ctx, p)
}
if err := resolver(); err != nil {
return xerror.New(op, err)
@@ -166,13 +126,8 @@ func markdownHandler(c echo.Context) error {
ctx := context.MustCastFromEchoContext(c)
logger := ctx.XLogger()
logger.DebugOp(op, "handling Markdown request...")
config := ctx.Config()
r := ctx.MustResource()
timeout, err := resource.WaitTimeoutAndWaitDelayArg(r, config)
if err != nil {
return err
}
opts, err := chromePrintOptions(r, config)
opts, err := chromePrinterOptions(r, ctx.Config())
if err != nil {
return err
}
@@ -180,11 +135,11 @@ func markdownHandler(c echo.Context) error {
if err != nil {
return err
}
prinry := ctx.Prinery()
printFunc := func(ctx timeoutContext.Context, logger xlog.Logger, dest string) error {
return prinry.Markdown(ctx, logger, dest, fpath, opts)
p, err := printer.NewMarkdownPrinter(logger, fpath, opts)
if err != nil {
return err
}
return convert(ctx, timeout, printFunc)
return convert(ctx, p)
}
if err := resolver(); err != nil {
return xerror.New(op, err)
@@ -200,13 +155,8 @@ func officeHandler(c echo.Context) error {
ctx := context.MustCastFromEchoContext(c)
logger := ctx.XLogger()
logger.DebugOp(op, "handling Office request...")
config := ctx.Config()
r := ctx.MustResource()
timeout, err := resource.WaitTimeoutAndWaitDelayArg(r, config)
if err != nil {
return err
}
opts, err := unoconvPrintOptions(r, config)
opts, err := officePrinterOptions(r, ctx.Config())
if err != nil {
return err
}
@@ -227,11 +177,8 @@ func officeHandler(c echo.Context) error {
if err != nil {
return err
}
prinry := ctx.Prinery()
printFunc := func(ctx timeoutContext.Context, logger xlog.Logger, dest string) error {
return prinry.Office(ctx, logger, dest, fpaths, opts)
}
return convert(ctx, timeout, printFunc)
p := printer.NewOfficePrinter(logger, fpaths, opts)
return convert(ctx, p)
}
if err := resolver(); err != nil {
return xerror.New(op, err)
@@ -239,11 +186,7 @@ func officeHandler(c echo.Context) error {
return nil
}
func convert(
ctx context.Context,
timeout float64,
printFunc func(ctx timeoutContext.Context, logger xlog.Logger, dest string) error,
) error {
func convert(ctx context.Context, p printer.Printer) error {
const op string = "xhttp.convert"
resolver := func() error {
logger := ctx.XLogger()
@@ -256,13 +199,13 @@ func convert(
// or an error.
if !r.HasArg(resource.WebhookURLArgKey) {
logger.DebugfOp(op, "no '%s' found, converting synchronously", resource.WebhookURLArgKey)
return convertSync(ctx, timeout, filename, fpath, printFunc)
return convertSync(ctx, p, filename, fpath)
}
// as a webhook URL has been given, we
// run the following lines in a goroutine so that
// it doesn't block.
logger.DebugfOp(op, "'%s' found, converting asynchronously", resource.WebhookURLArgKey)
return convertAsync(ctx, timeout, filename, fpath, printFunc)
return convertAsync(ctx, p, filename, fpath)
}
if err := resolver(); err != nil {
return xerror.New(op, err)
@@ -270,19 +213,13 @@ func convert(
return nil
}
func convertSync(
ctx context.Context,
timeout float64,
filename, dest string,
printFunc func(ctx timeoutContext.Context, logger xlog.Logger, dest string) error,
) error {
func convertSync(ctx context.Context, p printer.Printer, filename, fpath string) error {
const op = "xhttp.convertSync"
logger := ctx.XLogger()
r := ctx.MustResource()
timeoutCtx, cancel := xcontext.WithTimeout(logger, timeout)
defer cancel()
resolver := func() error {
if err := printFunc(timeoutCtx, logger, dest); err != nil {
logger := ctx.XLogger()
r := ctx.MustResource()
if err := p.Print(fpath); err != nil {
return err
}
if !r.HasArg(resource.ResultFilenameArgKey) {
@@ -292,7 +229,7 @@ func convertSync(
resource.RemoteURLArgKey,
filename,
)
if err := ctx.Attachment(dest, filename); err != nil {
if err := ctx.Attachment(fpath, filename); err != nil {
return err
}
return nil
@@ -306,26 +243,18 @@ func convertSync(
if err != nil {
return err
}
if err := ctx.Attachment(dest, filename); err != nil {
if err := ctx.Attachment(fpath, filename); err != nil {
return err
}
return nil
}
if err := resolver(); err != nil {
return xcontext.MustHandleError(
timeoutCtx,
xerror.New(op, err),
)
return xerror.New(op, err)
}
return nil
}
func convertAsync(
ctx context.Context,
timeout float64,
filename, dest string,
printFunc func(ctx timeoutContext.Context, logger xlog.Logger, dest string) error,
) error {
func convertAsync(ctx context.Context, p printer.Printer, filename, fpath string) error {
const op = "xhttp.convertAsync"
logger := ctx.XLogger()
r := ctx.MustResource()
@@ -339,14 +268,12 @@ func convertAsync(
}
go func() {
defer r.Close() // nolint: errcheck
timeoutCtx, cancel := xcontext.WithTimeout(logger, timeout)
defer cancel()
if err := printFunc(timeoutCtx, logger, dest); err != nil {
if err := p.Print(fpath); err != nil {
xerr := xerror.New(op, err)
logger.ErrorOp(xerror.Op(xerr), xerr)
return
}
f, err := os.Open(dest)
f, err := os.Open(fpath)
if err != nil {
xerr := xerror.New(op, err)
logger.ErrorOp(xerror.Op(xerr), xerr)

View File

@@ -19,8 +19,8 @@ import (
func TestPingHandler(t *testing.T) {
// should return 200.
config := conf.DefaultConfig()
// TODO
srv := New(config, nil, nil)
srv := New(config)
srv = New(config)
req := httptest.NewRequest(http.MethodGet, pingEndpoint, nil)
test.AssertStatusCode(t, http.StatusOK, srv, req)
// should returns a JSON as
@@ -28,8 +28,7 @@ func TestPingHandler(t *testing.T) {
os.Setenv(conf.LogLevelEnvVar, "DEBUG")
config, err := conf.FromEnv()
assert.Nil(t, err)
// TODO
srv = New(config, nil, nil)
srv = New(config)
req = httptest.NewRequest(http.MethodGet, pingEndpoint, nil)
rec := httptest.NewRecorder()
srv.ServeHTTP(rec, req)
@@ -40,8 +39,7 @@ func TestPingHandler(t *testing.T) {
func TestMergeHandler(t *testing.T) {
config := conf.DefaultConfig()
// TODO
srv := New(config, nil, nil)
srv := New(config)
// should return 200.
body, contentType := test.MergeMultipartForm(t, nil)
req := httptest.NewRequest(http.MethodPost, mergeEndpoint, body)
@@ -74,8 +72,7 @@ func TestMergeHandler(t *testing.T) {
func TestHTMLHandler(t *testing.T) {
config := conf.DefaultConfig()
// TODO
srv := New(config, nil, nil)
srv := New(config)
endpoint := fmt.Sprintf("%s%s", convertGroupEndpoint, htmlEndpoint)
// should return 200.
body, contentType := test.HTMLMultipartForm(t, nil)
@@ -205,8 +202,7 @@ func TestHTMLHandler(t *testing.T) {
func TestURLHandler(t *testing.T) {
config := conf.DefaultConfig()
// TODO
srv := New(config, nil, nil)
srv := New(config)
endpoint := fmt.Sprintf("%s%s", convertGroupEndpoint, urlEndpoint)
// should return 200.
body, contentType := test.URLMultipartForm(t, nil)
@@ -336,8 +332,7 @@ func TestURLHandler(t *testing.T) {
func TestMarkdownHandler(t *testing.T) {
config := conf.DefaultConfig()
// TODO
srv := New(config, nil, nil)
srv := New(config)
endpoint := fmt.Sprintf("%s%s", convertGroupEndpoint, markdownEndpoint)
// should return 200.
body, contentType := test.MarkdownMultipartForm(t, nil)
@@ -467,8 +462,7 @@ func TestMarkdownHandler(t *testing.T) {
func TestOfficeHandler(t *testing.T) {
config := conf.DefaultConfig()
// TODO
srv := New(config, nil, nil)
srv := New(config)
endpoint := fmt.Sprintf("%s%s", convertGroupEndpoint, officeEndpoint)
// should return 200.
body, contentType := test.OfficeMultipartForm(t, nil)
@@ -530,8 +524,7 @@ func TestWebhook(t *testing.T) {
rcv.Start(":3001")
}()
config := conf.DefaultConfig()
// TODO
srv := New(config, nil, nil)
srv := New(config)
// our custom server should receive the PDF.
body, contentType := test.MergeMultipartForm(t, map[string]string{string(resource.WebhookURLArgKey): "http://localhost:3001/foo"})
req := httptest.NewRequest(http.MethodPost, mergeEndpoint, body)
@@ -543,8 +536,7 @@ func TestWebhook(t *testing.T) {
func TestResultFilename(t *testing.T) {
config := conf.DefaultConfig()
// TODO
srv := New(config, nil, nil)
srv := New(config)
body, contentType := test.MergeMultipartForm(t, map[string]string{string(resource.ResultFilenameArgKey): "foo.pdf"})
req := httptest.NewRequest(http.MethodPost, mergeEndpoint, body)
req.Header.Set(echo.HeaderContentType, contentType)

View File

@@ -7,7 +7,6 @@ import (
"github.com/thecodingmachine/gotenberg/internal/app/xhttp/pkg/context"
"github.com/thecodingmachine/gotenberg/internal/app/xhttp/pkg/resource"
"github.com/thecodingmachine/gotenberg/internal/pkg/conf"
"github.com/thecodingmachine/gotenberg/internal/pkg/prinery"
"github.com/thecodingmachine/gotenberg/internal/pkg/xerror"
"github.com/thecodingmachine/gotenberg/internal/pkg/xlog"
"github.com/thecodingmachine/gotenberg/internal/pkg/xrand"
@@ -15,7 +14,7 @@ import (
// contextMiddleware extends the default echo.Context with
// our custom context.Context.
func contextMiddleware(config conf.Config, prinry prinery.Prinery) echo.MiddlewareFunc {
func contextMiddleware(config conf.Config) echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
// generate a unique identifier for the request.
@@ -25,7 +24,7 @@ func contextMiddleware(config conf.Config, prinry prinery.Prinery) echo.Middlewa
logger := xlog.New(config.LogLevel(), trace)
// extend the current echo context with our custom
// context.
ctx := context.New(c, logger, config, prinry)
ctx := context.New(c, logger, config)
// if its an healthcheck request, there
// is no need to create a Resource.
if ctx.Path() == pingEndpoint {

View File

@@ -3,37 +3,53 @@ package xhttp
import (
"github.com/thecodingmachine/gotenberg/internal/app/xhttp/pkg/resource"
"github.com/thecodingmachine/gotenberg/internal/pkg/conf"
"github.com/thecodingmachine/gotenberg/internal/pkg/prinery"
"github.com/thecodingmachine/gotenberg/internal/pkg/printer"
"github.com/thecodingmachine/gotenberg/internal/pkg/xerror"
)
func chromePrintOptions(r resource.Resource, config conf.Config) (prinery.ChromePrintOptions, error) {
const op string = "xhttp.chromePrintOptions"
resolver := func() (prinery.ChromePrintOptions, error) {
func mergePrinterOptions(r resource.Resource, config conf.Config) (printer.MergePrinterOptions, error) {
const op string = "xhttp.mergePrinterOptions"
waitTimeout, err := resource.WaitTimeoutArg(r, config)
if err != nil {
return printer.MergePrinterOptions{}, xerror.New(op, err)
}
return printer.MergePrinterOptions{
WaitTimeout: waitTimeout,
}, nil
}
func chromePrinterOptions(r resource.Resource, config conf.Config) (printer.ChromePrinterOptions, error) {
const op string = "xhttp.chromePrinterOptions"
resolver := func() (printer.ChromePrinterOptions, error) {
waitTimeout, err := resource.WaitTimeoutArg(r, config)
if err != nil {
return printer.ChromePrinterOptions{}, err
}
waitDelay, err := resource.WaitDelayArg(r, config)
if err != nil {
return prinery.ChromePrintOptions{}, err
return printer.ChromePrinterOptions{}, err
}
headerHTML, footerHTML,
err := resource.HeaderFooterContents(r, config)
if err != nil {
return prinery.ChromePrintOptions{}, err
return printer.ChromePrinterOptions{}, err
}
paperWidth, paperHeight,
err := resource.PaperSizeArgs(r, config)
if err != nil {
return prinery.ChromePrintOptions{}, err
return printer.ChromePrinterOptions{}, err
}
marginTop, marginBottom, marginLeft, marginRight,
err := resource.MarginArgs(r, config)
if err != nil {
return prinery.ChromePrintOptions{}, err
return printer.ChromePrinterOptions{}, err
}
landscape, err := r.BoolArg(resource.LandscapeArgKey, false)
if err != nil {
return prinery.ChromePrintOptions{}, err
return printer.ChromePrinterOptions{}, err
}
return prinery.ChromePrintOptions{
return printer.ChromePrinterOptions{
WaitTimeout: waitTimeout,
WaitDelay: waitDelay,
HeaderHTML: headerHTML,
FooterHTML: footerHTML,
@@ -53,15 +69,20 @@ func chromePrintOptions(r resource.Resource, config conf.Config) (prinery.Chrome
return opts, nil
}
func unoconvPrintOptions(r resource.Resource, config conf.Config) (prinery.UnoconvPrintOptions, error) {
const op string = "xhttp.unoconvPrintOptions"
resolver := func() (prinery.UnoconvPrintOptions, error) {
func officePrinterOptions(r resource.Resource, config conf.Config) (printer.OfficePrinterOptions, error) {
const op string = "xhttp.officePrinterOptions"
resolver := func() (printer.OfficePrinterOptions, error) {
waitTimeout, err := resource.WaitTimeoutArg(r, config)
if err != nil {
return printer.OfficePrinterOptions{}, err
}
landscape, err := r.BoolArg(resource.LandscapeArgKey, false)
if err != nil {
return prinery.UnoconvPrintOptions{}, err
return printer.OfficePrinterOptions{}, err
}
return prinery.UnoconvPrintOptions{
Landscape: landscape,
return printer.OfficePrinterOptions{
WaitTimeout: waitTimeout,
Landscape: landscape,
}, nil
}
opts, err := resolver()

View File

@@ -13,7 +13,6 @@ import (
"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/prinery"
"github.com/thecodingmachine/gotenberg/internal/pkg/xerror"
"github.com/thecodingmachine/gotenberg/internal/pkg/xlog"
)
@@ -23,23 +22,16 @@ type Context struct {
echo.Context
logger xlog.Logger
config conf.Config
prinry prinery.Prinery
resource resource.Resource
startTime time.Time
}
// New creates a new Context.
func New(
c echo.Context,
logger xlog.Logger,
config conf.Config,
prinry prinery.Prinery,
) Context {
func New(c echo.Context, logger xlog.Logger, config conf.Config) Context {
return Context{
c,
logger,
config,
prinry,
resource.Resource{},
time.Now(),
}
@@ -78,29 +70,6 @@ func (ctx Context) Config() conf.Config {
return ctx.config
}
// ProcessesHealthcheck returns an error if
// one of the processes is not viable.
func (ctx Context) ProcessesHealthcheck() error {
const op string = "context.Context.ProcessesHealthcheck"
// TODO
/*processes := ctx.manager.All()
for _, p := range processes {
if !ctx.manager.IsViable(p) {
return xerror.New(
op,
fmt.Errorf("'%s' is not viable", p.ID()),
)
}
}*/
return nil
}
// Prinery returns the instance of prinery.Prinery
// associated with the Context.
func (ctx Context) Prinery() prinery.Prinery {
return ctx.prinry
}
// WithResource creates a resource.Resource and
// adds it to the Context.
func (ctx *Context) WithResource(directoryName string) error {

View File

@@ -6,7 +6,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/thecodingmachine/gotenberg/internal/pkg/conf"
"github.com/thecodingmachine/gotenberg/internal/pkg/pm2"
"github.com/thecodingmachine/gotenberg/test"
)
@@ -27,27 +26,6 @@ func TestMustCastFromEchoContext(t *testing.T) {
})
}
func TestProcessesHealthcheck(t *testing.T) {
// process is viable.
ctx := New(
test.DummyEchoContext(),
test.DebugLogger(),
conf.DefaultConfig(),
pm2.NewDummyProcess(true),
)
err := ctx.ProcessesHealthcheck()
assert.Nil(t, err)
// process is not viable.
ctx = New(
test.DummyEchoContext(),
test.DebugLogger(),
conf.DefaultConfig(),
pm2.NewDummyProcess(false),
)
err = ctx.ProcessesHealthcheck()
test.AssertError(t, err)
}
func TestLogRequestResult(t *testing.T) {
ctx := New(
test.DummyEchoContext(),

View File

@@ -76,34 +76,6 @@ func ArgKeys() []ArgKey {
}
}
/*
WaitTimeoutAndWaitDelayArg is a helper for retrieving
the sum of "waitTimeout" and "waitDelay" arguments
as float64.
It also validates them against the application
configuration.
*/
func WaitTimeoutAndWaitDelayArg(r Resource, config conf.Config) (float64, error) {
const op string = "resource.WaitTimeoutAndWaitDelayArg"
resolver := func() (float64, error) {
waitTimeout, err := WaitTimeoutArg(r, config)
if err != nil {
return waitTimeout, err
}
waitDelay, err := WaitDelayArg(r, config)
if err != nil {
return waitDelay, err
}
return waitTimeout + waitDelay, nil
}
combined, err := resolver()
if err != nil {
return combined, xerror.New(op, err)
}
return combined, nil
}
/*
WaitTimeoutArg is a helper for retrieving
the "waitTimeout" argument as float64.

View File

@@ -3,15 +3,14 @@ package xhttp
import (
"github.com/labstack/echo/v4"
"github.com/thecodingmachine/gotenberg/internal/pkg/conf"
"github.com/thecodingmachine/gotenberg/internal/pkg/prinery"
)
// New returns a custom echo.Echo.
func New(config conf.Config, prinry prinery.Prinery) *echo.Echo {
func New(config conf.Config) *echo.Echo {
srv := echo.New()
srv.HideBanner = true
srv.HidePort = true
srv.Use(contextMiddleware(config, prinry))
srv.Use(contextMiddleware(config))
srv.Use(loggerMiddleware())
srv.Use(cleanupMiddleware())
srv.Use(errorMiddleware())

View File

@@ -17,8 +17,7 @@ func TestDisableChromeEndpoints(t *testing.T) {
os.Setenv(conf.DisableGoogleChromeEnvVar, "1")
config, err := conf.FromEnv()
assert.Nil(t, err)
// TODO
srv := New(config, nil, nil)
srv := New(config)
// Ping endpoint should return 200.
req := httptest.NewRequest(http.MethodGet, pingEndpoint, nil)
test.AssertStatusCode(t, http.StatusOK, srv, req)
@@ -55,8 +54,7 @@ func TestDisableUnoconvEndpoints(t *testing.T) {
os.Setenv(conf.DisableUnoconvEnvVar, "1")
config, err := conf.FromEnv()
assert.Nil(t, err)
// TODO
srv := New(config, nil, nil)
srv := New(config)
// Ping endpoint should return 200.
req := httptest.NewRequest(http.MethodGet, pingEndpoint, nil)
test.AssertStatusCode(t, http.StatusOK, srv, req)
@@ -93,8 +91,7 @@ func TestDisableChromeAndUnoconvEndpoints(t *testing.T) {
os.Setenv(conf.DisableUnoconvEnvVar, "1")
config, err := conf.FromEnv()
assert.Nil(t, err)
// TODO
srv := New(config, nil, nil)
srv := New(config)
// Ping endpoint should return 200.
req := httptest.NewRequest(http.MethodGet, pingEndpoint, nil)
test.AssertStatusCode(t, http.StatusOK, srv, req)