feat(invoice): add send route

This commit is contained in:
2025-08-26 20:30:48 +02:00
parent 958979c62b
commit 788571162d
35 changed files with 451 additions and 193 deletions

View File

@@ -13,12 +13,13 @@ type Service struct {
gotenberg *gotenberg.Client
}
func New(hostname string) (service Service, err error) {
func New(hostname string) (service *Service, err error) {
service = &Service{}
service.gotenberg, err = gotenberg.NewClient(hostname, http.DefaultClient)
return
}
func (s Service) HtmlToPdf(html string) (pdf io.ReadCloser, err error) {
func (s *Service) HtmlToPdf(html string) (pdf io.ReadCloser, err error) {
index, err := document.FromString("index.html", html)
if err != nil {
return
@@ -32,6 +33,9 @@ func (s Service) HtmlToPdf(html string) (pdf io.ReadCloser, err error) {
req.EmulatePrintMediaType()
resp, err := s.gotenberg.Send(context.Background(), req)
if err != nil {
return
}
pdf = resp.Body
return