Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -9,21 +9,21 @@ import (
|
||||
"github.com/jung-kurt/gofpdf"
|
||||
)
|
||||
|
||||
func resolvePdfAssetPath(name string) (string, error) {
|
||||
|
||||
base := strings.TrimSpace(os.Getenv("PDF_FONT_DIR"))
|
||||
|
||||
if base == "" {
|
||||
base = "/opt/bssapp/svc/fonts"
|
||||
func resolvePdfAssetPath(envKey string) (string, error) {
|
||||
path := os.Getenv(envKey)
|
||||
if path == "" {
|
||||
return "", fmt.Errorf("env %s not set", envKey)
|
||||
}
|
||||
|
||||
p := filepath.Join(base, name)
|
||||
|
||||
if _, err := os.Stat(p); err != nil {
|
||||
return "", fmt.Errorf("font not found: %s", p)
|
||||
if !filepath.IsAbs(path) {
|
||||
return "", fmt.Errorf("font path must be absolute: %s", path)
|
||||
}
|
||||
|
||||
return p, nil
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return path, nil
|
||||
}
|
||||
|
||||
func resolvePdfImagePath(fileName string) (string, error) {
|
||||
|
||||
Reference in New Issue
Block a user