mirror of
https://github.com/vbatts/srvdav.git
synced 2025-07-25 19:50:26 +00:00
vendoring and caldav
This commit is contained in:
parent
a06aa900b7
commit
fd9092e5ab
96 changed files with 14832 additions and 5 deletions
49
vendor/github.com/samedi/caldav-go/handlers/propfind.go
generated
vendored
Normal file
49
vendor/github.com/samedi/caldav-go/handlers/propfind.go
generated
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"encoding/xml"
|
||||
"github.com/samedi/caldav-go/global"
|
||||
)
|
||||
|
||||
type propfindHandler struct {
|
||||
request *http.Request
|
||||
response *Response
|
||||
}
|
||||
|
||||
func (ph propfindHandler) Handle() *Response {
|
||||
requestBody := readRequestBody(ph.request)
|
||||
header := headers{ph.request.Header}
|
||||
|
||||
// get the target resources based on the request URL
|
||||
resources, err := global.Storage.GetResources(ph.request.URL.Path, header.IsDeep())
|
||||
if err != nil {
|
||||
return ph.response.SetError(err)
|
||||
}
|
||||
|
||||
// read body string to xml struct
|
||||
type XMLProp2 struct {
|
||||
Tags []xml.Name `xml:",any"`
|
||||
}
|
||||
type XMLRoot2 struct {
|
||||
XMLName xml.Name
|
||||
Prop XMLProp2 `xml:"DAV: prop"`
|
||||
}
|
||||
var requestXML XMLRoot2
|
||||
xml.Unmarshal([]byte(requestBody), &requestXML)
|
||||
|
||||
multistatus := &multistatusResp{
|
||||
Minimal: header.IsMinimal(),
|
||||
}
|
||||
// for each href, build the multistatus responses
|
||||
for _, resource := range resources {
|
||||
propstats := multistatus.Propstats(&resource, requestXML.Prop.Tags)
|
||||
multistatus.AddResponse(resource.Path, true, propstats)
|
||||
}
|
||||
|
||||
if multistatus.Minimal {
|
||||
ph.response.SetHeader(HD_PREFERENCE_APPLIED, HD_PREFER_MINIMAL)
|
||||
}
|
||||
|
||||
return ph.response.Set(207, multistatus.ToXML())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue