Files
zurg/pkg/dav/response.go
Ben Sarmiento c8334ecb3b Hotfix
2023-11-27 21:50:00 +01:00

23 lines
1.1 KiB
Go

package dav
import (
"fmt"
"path/filepath"
)
// optimized versions, no more marshalling
func BaseDirectory(path, added string) string {
return fmt.Sprintf("<d:response><d:href>/%s</d:href><d:propstat><d:prop><d:resourcetype><d:collection/></d:resourcetype><d:getlastmodified>%s</d:getlastmodified></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response>", customPathEscape(path), added)
}
func Directory(path, added string) string {
path = filepath.Base(path)
return fmt.Sprintf("<d:response><d:href>%s</d:href><d:propstat><d:prop><d:resourcetype><d:collection/></d:resourcetype><d:getlastmodified>%s</d:getlastmodified></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response>", customPathEscape(path), added)
}
func File(path string, fileSize int64, added string) string {
path = filepath.Base(path)
return fmt.Sprintf("<d:response><d:href>%s</d:href><d:propstat><d:prop><d:resourcetype></d:resourcetype><d:getcontentlength>%d</d:getcontentlength><d:getlastmodified>%s</d:getlastmodified></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response>", customPathEscape(path), fileSize, added)
}