Optimize webdav
This commit is contained in:
@@ -1,27 +1,39 @@
|
||||
package dav
|
||||
|
||||
func Directory(path string) Response {
|
||||
import "fmt"
|
||||
|
||||
func DavDirectory(path, added string) Response {
|
||||
return Response{
|
||||
Href: "/" + customPathEscape(path),
|
||||
Propstat: PropStat{
|
||||
Prop: Prop{
|
||||
ResourceType: ResourceType{Value: "<d:collection/>"},
|
||||
LastModified: added,
|
||||
},
|
||||
Status: "HTTP/1.1 200 OK",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func File(path string, fileSize int64, added string, link string) Response {
|
||||
func DavFile(path string, fileSize int64, added string, link string) Response {
|
||||
return Response{
|
||||
Href: "/" + customPathEscape(path),
|
||||
Propstat: PropStat{
|
||||
Prop: Prop{
|
||||
ContentLength: fileSize,
|
||||
CreationDate: added,
|
||||
LastModified: added,
|
||||
},
|
||||
Status: "HTTP/1.1 200 OK",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// optimized versions, no more marshalling
|
||||
|
||||
func Directory(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:prop><d:prop><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 {
|
||||
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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user