mirror of
https://github.com/Luzifer/tex-api.git
synced 2024-11-09 16:50:03 +00:00
26 lines
607 B
Go
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
|
|
}
|