mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-14 19:32:15 +01:00
wip refactoring: better logging and error systems
This commit is contained in:
37
internal/app/api/pkg/handler/office.go
Normal file
37
internal/app/api/pkg/handler/office.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/thecodingmachine/gotenberg/internal/app/api/pkg/context"
|
||||
"github.com/thecodingmachine/gotenberg/internal/pkg/printer"
|
||||
)
|
||||
|
||||
// Office is the endpoint for converting
|
||||
// Office files to PDF.
|
||||
func Office(c echo.Context) error {
|
||||
ctx := context.MustCastFromEchoContext(c)
|
||||
r := ctx.Resource()
|
||||
opts, err := r.OfficePrinterOptions()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fpaths, err := r.Fpaths(
|
||||
".txt",
|
||||
".rtf",
|
||||
".fodt",
|
||||
".doc",
|
||||
".docx",
|
||||
".odt",
|
||||
".xls",
|
||||
".xlsx",
|
||||
".ods",
|
||||
".ppt",
|
||||
".pptx",
|
||||
".odp",
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p := printer.NewOffice(fpaths, opts)
|
||||
return convert(ctx, p)
|
||||
}
|
||||
Reference in New Issue
Block a user