feat(invoice): add send route
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user