1
0
Fork 0
mirror of https://github.com/Luzifer/tex-api.git synced 2024-11-08 16:20:04 +00:00
tex-api/helpers.go
Knut Ahlers 8351f95564
Refactor & add support for direct PDF download
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2023-09-06 12:41:33 +02:00

26 lines
607 B
Go

package main
import (
"net/http"
"net/url"
"path"
"github.com/gofrs/uuid"
"github.com/sirupsen/logrus"
)
func pathFromUUID(uid uuid.UUID, filename string) string {
return path.Join(cfg.StorageDir, uid.String(), filename)
}
func serverErrorf(res http.ResponseWriter, err error, tpl string, args ...interface{}) {
logrus.WithError(err).Errorf(tpl, args...)
http.Error(res, "An error occurred. See details in log.", http.StatusInternalServerError)
}
func urlMust(u *url.URL, err error) *url.URL {
if err != nil {
logrus.WithError(err).Fatal("Unable to retrieve URL from router")
}
return u
}