mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-10 12:46:53 +00:00
force to set pdf service
This commit is contained in:
parent
6a25589751
commit
a31a1f6350
2 changed files with 16 additions and 6 deletions
|
|
@ -24,13 +24,19 @@ type PdfService struct {
|
|||
apiKey string
|
||||
}
|
||||
|
||||
func NewPdfService() *PdfService {
|
||||
func NewPdfService() (*PdfService, error) {
|
||||
pid := os.Getenv("HTMLDOCS_PROJECT_ID")
|
||||
url := os.Getenv("HTMLDOCS_URL")
|
||||
key := os.Getenv("HTMLDOCS_KEY")
|
||||
if pid == "" || url == "" || key == "" {
|
||||
return nil, errors.New("error building Pdf service. Verify your env variables")
|
||||
}
|
||||
return &PdfService{
|
||||
invoicePath: "index.html",
|
||||
projectId: os.Getenv("HTMLDOCS_PROJECT_ID"),
|
||||
url: os.Getenv("HTMLDOCS_URL"),
|
||||
apiKey: os.Getenv("HTMLDOCS_KEY"),
|
||||
}
|
||||
projectId: pid,
|
||||
url: url,
|
||||
apiKey: key,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (ps PdfService) BuildInvoice(b *booking.Booking, hc *config.Host) error {
|
||||
|
|
|
|||
6
main.go
6
main.go
|
|
@ -38,5 +38,9 @@ func main() {
|
|||
log.Fatalf("error migrating the database %s\n", err)
|
||||
}
|
||||
|
||||
server.New(&static, booking.NewService(db), pdf.NewPdfService(), config.NewHost()).Start()
|
||||
ps, err := pdf.NewPdfService()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
server.New(&static, booking.NewService(db), ps, config.NewHost()).Start()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue