Use NewHTTPError to return better errors

That function is merged upstream, but the current version still depends
on some stuff not yet merged into upstream go-webdav.
This commit is contained in:
Conrad Hoffmann 2022-05-03 17:00:07 +02:00
parent c2f35df455
commit 4765adc1a3
4 changed files with 27 additions and 14 deletions

View file

@ -66,15 +66,18 @@ func (u *tokidokiHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}
opts := webdav.ServeUserPrincipalOptions{
UserPrincipalPath: userPrincipalPath,
HomeSets: homeSets,
}
if r.URL.Path == userPrincipalPath {
opts := webdav.ServeUserPrincipalOptions{
UserPrincipalPath: userPrincipalPath,
HomeSets: homeSets,
}
if webdav.ServeUserPrincipal(w, r, opts) {
webdav.ServeUserPrincipal(w, r, &opts)
return
}
// TODO serve something on / that signals this being a DAV server?
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
}