Files
gotenberg/internal/app/api/pkg/handler/html.go
2019-07-07 17:45:07 +02:00

25 lines
548 B
Go

package handler
import (
"github.com/labstack/echo/v4"
"github.com/thecodingmachine/gotenberg/internal/app/api/pkg/context"
"github.com/thecodingmachine/gotenberg/internal/pkg/printer"
)
// HTML is the endpoint for converting
// HTML to PDF.
func HTML(c echo.Context) error {
ctx := context.MustCastFromEchoContext(c)
r := ctx.Resource()
opts, err := r.ChromePrinterOptions()
if err != nil {
return err
}
fpath, err := r.Fpath("index.html")
if err != nil {
return err
}
p := printer.NewHTML(fpath, opts)
return convert(ctx, p)
}