Documentation ¶
Index ¶
- Constants
- func HandleErrorStatus(log *zerolog.Logger, w http.ResponseWriter, s *rpc.Status)
- func HandleWebdavError(log *zerolog.Logger, w http.ResponseWriter, b []byte, err error)
- func Marshal(e exception) ([]byte, error)
- func New(m map[string]interface{}, log *zerolog.Logger) (global.Service, error)
- type AvatarsHandler
- type Config
- type DavHandler
- type MetaHandler
- type PerfResponse
- type Proppatch
- type PublicFileHandler
- type SpacesHandler
- type TrashbinHandler
- type VersionsHandler
- type WebDavHandler
- type WriteCounter
Constants ¶
const ( // SabredavBadRequest maps to HTTP 400 SabredavBadRequest code = iota // SabredavMethodNotAllowed maps to HTTP 405 SabredavMethodNotAllowed // SabredavNotAuthenticated maps to HTTP 401 SabredavNotAuthenticated // SabredavPreconditionFailed maps to HTTP 412 SabredavPreconditionFailed // SabredavPermissionDenied maps to HTTP 403 SabredavPermissionDenied // SabredavNotFound maps to HTTP 404 SabredavNotFound // SabredavConflict maps to HTTP 409 SabredavConflict )
const ( MethodPropfind = "PROPFIND" MethodLock = "LOCK" MethodUnlock = "UNLOCK" MethodProppatch = "PROPPATCH" MethodMkcol = "MKCOL" MethodMove = "MOVE" MethodCopy = "COPY" MethodReport = "REPORT" )
Common Webdav methods.
Unless otherwise noted, these are defined in RFC 4918 section 9.
const ( HeaderAcceptRanges = "Accept-Ranges" HeaderAccessControlAllowHeaders = "Access-Control-Allow-Headers" HeaderAccessControlExposeHeaders = "Access-Control-Expose-Headers" HeaderContentDisposistion = "Content-Disposition" HeaderContentLength = "Content-Length" HeaderContentRange = "Content-Range" HeaderContentType = "Content-Type" HeaderETag = "ETag" HeaderLastModified = "Last-Modified" HeaderLocation = "Location" HeaderRange = "Range" HeaderIfMatch = "If-Match" HeaderChecksum = "Digest" )
Common HTTP headers.
const ( HeaderOCFileID = "OC-FileId" HeaderOCETag = "OC-ETag" HeaderOCChecksum = "OC-Checksum" HeaderOCPermissions = "OC-Perm" HeaderDepth = "Depth" HeaderDav = "DAV" HeaderTusResumable = "Tus-Resumable" HeaderTusVersion = "Tus-Version" HeaderTusExtension = "Tus-Extension" HeaderTusChecksumAlgorithm = "Tus-Checksum-Algorithm" HeaderTusUploadExpires = "Upload-Expires" HeaderDestination = "Destination" HeaderOverwrite = "Overwrite" HeaderUploadChecksum = "Upload-Checksum" HeaderUploadLength = "Upload-Length" HeaderUploadMetadata = "Upload-Metadata" HeaderUploadOffset = "Upload-Offset" HeaderOCMtime = "X-OC-Mtime" HeaderExpectedEntityLength = "X-Expected-Entity-Length" HeaderTransferAuth = "TransferHeaderAuthorization" )
Non standard HTTP headers.
const ( // PerfMarkerResponseTime corresponds to the interval at which a performance marker is sent back to the TPC client PerfMarkerResponseTime float64 = 5 )
const (
// RFC1123 time that mimics oc10. time.RFC1123 would end in "UTC", see https://github.com/golang/go/issues/13781
RFC1123 = "Mon, 02 Jan 2006 15:04:05 GMT"
)
Variables ¶
This section is empty.
Functions ¶
func HandleErrorStatus ¶ added in v0.0.2
HandleErrorStatus checks the status code, logs a Debug or Error level message and writes an appropriate http status
func HandleWebdavError ¶ added in v0.0.2
HandleWebdavError checks the status code, logs an error and creates a webdav response body if needed
Types ¶
type AvatarsHandler ¶
type AvatarsHandler struct { }
AvatarsHandler handles avatar requests
func (*AvatarsHandler) Handler ¶
func (h *AvatarsHandler) Handler(s *svc) http.Handler
Handler handles requests
type Config ¶
type Config struct { Prefix string `mapstructure:"prefix"` // FilesNamespace prefixes the namespace, optionally with user information. // Example: if FilesNamespace is /users/{{substr 0 1 .Username}}/{{.Username}} // and received path is /docs the internal path will be: // /users/<first char of username>/<username>/docs FilesNamespace string `mapstructure:"files_namespace"` // WebdavNamespace prefixes the namespace, optionally with user information. // Example: if WebdavNamespace is /users/{{substr 0 1 .Username}}/{{.Username}} // and received path is /docs the internal path will be: // /users/<first char of username>/<username>/docs WebdavNamespace string `mapstructure:"webdav_namespace"` GatewaySvc string `mapstructure:"gatewaysvc"` Timeout int64 `mapstructure:"timeout"` Insecure bool `mapstructure:"insecure" docs:"false;Whether to skip certificate checks when sending requests."` // If true, HTTP COPY will expect the HTTP-TPC (third-party copy) headers EnableHTTPTpc bool `mapstructure:"enable_http_tpc"` PublicURL string `mapstructure:"public_url"` FavoriteStorageDriver string `mapstructure:"favorite_storage_driver"` FavoriteStorageDrivers map[string]map[string]interface{} `mapstructure:"favorite_storage_drivers"` }
Config holds the config options that need to be passed down to all ocdav handlers
type DavHandler ¶
type DavHandler struct { AvatarsHandler *AvatarsHandler FilesHandler *WebDavHandler FilesHomeHandler *WebDavHandler MetaHandler *MetaHandler TrashbinHandler *TrashbinHandler SpacesHandler *SpacesHandler PublicFolderHandler *WebDavHandler PublicFileHandler *PublicFileHandler }
DavHandler routes to the different sub handlers
func (*DavHandler) Handler ¶
func (h *DavHandler) Handler(s *svc) http.Handler
Handler handles requests
type MetaHandler ¶
type MetaHandler struct {
VersionsHandler *VersionsHandler
}
MetaHandler handles meta requests
func (*MetaHandler) Handler ¶
func (h *MetaHandler) Handler(s *svc) http.Handler
Handler handles requests
type PerfResponse ¶ added in v0.0.2
PerfResponse provides a single chunk of permormance marker response
type Proppatch ¶
type Proppatch struct { // Remove specifies whether this patch removes properties. If it does not // remove them, it sets them. Remove bool // Props contains the properties to be set or removed. Props []propertyXML }
Proppatch describes a property update instruction as defined in RFC 4918. See http://www.webdav.org/specs/rfc4918.html#METHOD_PROPPATCH
type PublicFileHandler ¶ added in v0.0.2
type PublicFileHandler struct {
// contains filtered or unexported fields
}
PublicFileHandler handles requests on a shared file. it needs to be wrapped in a collection
func (*PublicFileHandler) Handler ¶ added in v0.0.2
func (h *PublicFileHandler) Handler(s *svc) http.Handler
Handler handles requests
type SpacesHandler ¶ added in v0.0.2
type SpacesHandler struct {
// contains filtered or unexported fields
}
SpacesHandler handles trashbin requests
func (*SpacesHandler) Handler ¶ added in v0.0.2
func (h *SpacesHandler) Handler(s *svc) http.Handler
Handler handles requests
type TrashbinHandler ¶
type TrashbinHandler struct {
// contains filtered or unexported fields
}
TrashbinHandler handles trashbin requests
func (*TrashbinHandler) Handler ¶
func (h *TrashbinHandler) Handler(s *svc) http.Handler
Handler handles requests
type VersionsHandler ¶
type VersionsHandler struct { }
VersionsHandler handles version requests
func (*VersionsHandler) Handler ¶
func (h *VersionsHandler) Handler(s *svc, rid *provider.ResourceId) http.Handler
Handler handles requests versions can be listed with a PROPFIND to /remote.php/dav/meta/<fileid>/v a version is identified by a timestamp, eg. /remote.php/dav/meta/<fileid>/v/1561410426
type WebDavHandler ¶
type WebDavHandler struct {
// contains filtered or unexported fields
}
WebDavHandler implements a dav endpoint
func (*WebDavHandler) Handler ¶
func (h *WebDavHandler) Handler(s *svc) http.Handler
Handler handles requests
type WriteCounter ¶ added in v0.0.2
type WriteCounter struct { Total uint64 PrevTime time.Time // contains filtered or unexported fields }
WriteCounter counts the number of bytes transferred and reports back to the TPC client about the progress of the transfer through the performance marker response stream.
func (*WriteCounter) SendPerfMarker ¶ added in v0.0.2
func (wc *WriteCounter) SendPerfMarker(size uint64)
SendPerfMarker flushes a single chunk (performance marker) as part of the chunked transfer encoding scheme.