Documentation ¶
Index ¶
- Constants
- Variables
- func New(m map[string]interface{}, log *zerolog.Logger) (global.Service, error)
- func NewWith(conf *config.Config, fm favorite.Manager, ls LockSystem, _ *zerolog.Logger, ...) (global.Service, error)
- func ValidateName(name string, validators []Validator) error
- type AvatarsHandler
- type Condition
- type DavHandler
- type LockDetails
- type LockSystem
- type MetaHandler
- type PerfResponse
- type Proppatch
- type PublicFileHandler
- type SpacesHandler
- type TrashbinHandler
- type Validator
- type VersionsHandler
- type WebDavHandler
- type WriteCounter
Constants ¶
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 ( // PerfMarkerResponseTime corresponds to the interval at which a performance marker is sent back to the TPC client PerfMarkerResponseTime float64 = 5 )
Variables ¶
var Propagator = propagation.NewCompositeTextMapPropagator( propagation.Baggage{}, propagation.TraceContext{}, )
Propagator ensures the importer module uses the same trace propagation strategy.
Functions ¶
func NewWith ¶ added in v2.2.0
func NewWith(conf *config.Config, fm favorite.Manager, ls LockSystem, _ *zerolog.Logger, selector pool.Selectable[gateway.GatewayAPIClient]) (global.Service, error)
NewWith returns a new ocdav service
func ValidateName ¶ added in v2.13.0
ValidateName will validate a file or folder name, returning an error when it is not accepted
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 Condition ¶
Condition can match a WebDAV resource, based on a token or ETag. Exactly one of Token and ETag should be non-empty.
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 LockDetails ¶
type LockDetails struct { // Root is the root resource name being locked. For a zero-depth lock, the // root is the only resource being locked. Root *provider.Reference // Duration is the lock timeout. A negative duration means infinite. Duration time.Duration // OwnerXML is the verbatim <owner> XML given in a LOCK HTTP request. // // TODO: does the "verbatim" nature play well with XML namespaces? // Does the OwnerXML field need to have more structure? See // https://codereview.appspot.com/175140043/#msg2 OwnerXML string UserID *userpb.UserId // ZeroDepth is whether the lock has zero depth. If it does not have zero // depth, it has infinite depth. ZeroDepth bool }
LockDetails are a lock's metadata.
type LockSystem ¶
type LockSystem interface { // Confirm confirms that the caller can claim all of the locks specified by // the given conditions, and that holding the union of all of those locks // gives exclusive access to all of the named resources. Up to two resources // can be named. Empty names are ignored. // // Exactly one of release and err will be non-nil. If release is non-nil, // all of the requested locks are held until release is called. Calling // release does not unlock the lock, in the WebDAV UNLOCK sense, but once // Confirm has confirmed that a lock claim is valid, that lock cannot be // Confirmed again until it has been released. // // If Confirm returns ErrConfirmationFailed then the Handler will continue // to try any other set of locks presented (a WebDAV HTTP request can // present more than one set of locks). If it returns any other non-nil // error, the Handler will write a "500 Internal Server Error" HTTP status. Confirm(ctx context.Context, now time.Time, name0, name1 string, conditions ...Condition) (release func(), err error) // Create creates a lock with the given depth, duration, owner and root // (name). The depth will either be negative (meaning infinite) or zero. // // If Create returns ErrLocked then the Handler will write a "423 Locked" // HTTP status. If it returns any other non-nil error, the Handler will // write a "500 Internal Server Error" HTTP status. // // See http://www.webdav.org/specs/rfc4918.html#rfc.section.9.10.6 for // when to use each error. // // The token returned identifies the created lock. It should be an absolute // URI as defined by RFC 3986, Section 4.3. In particular, it should not // contain whitespace. Create(ctx context.Context, now time.Time, details LockDetails) (token string, err error) // Refresh refreshes the lock with the given token. // // If Refresh returns ErrLocked then the Handler will write a "423 Locked" // HTTP Status. If Refresh returns ErrNoSuchLock then the Handler will write // a "412 Precondition Failed" HTTP Status. If it returns any other non-nil // error, the Handler will write a "500 Internal Server Error" HTTP status. // // See http://www.webdav.org/specs/rfc4918.html#rfc.section.9.10.6 for // when to use each error. Refresh(ctx context.Context, now time.Time, token string, duration time.Duration) (LockDetails, error) // Unlock unlocks the lock with the given token. // // If Unlock returns ErrForbidden then the Handler will write a "403 // Forbidden" HTTP Status. If Unlock returns ErrLocked then the Handler // will write a "423 Locked" HTTP status. If Unlock returns ErrNoSuchLock // then the Handler will write a "409 Conflict" HTTP Status. If it returns // any other non-nil error, the Handler will write a "500 Internal Server // Error" HTTP status. // // See http://www.webdav.org/specs/rfc4918.html#rfc.section.9.11.1 for // when to use each error. Unlock(ctx context.Context, now time.Time, ref *provider.Reference, token string) error }
LockSystem manages access to a collection of named resources. The elements in a lock name are separated by slash ('/', U+002F) characters, regardless of host operating system convention.
func NewCS3LS ¶
func NewCS3LS(s pool.Selectable[gateway.GatewayAPIClient]) LockSystem
NewCS3LS returns a new CS3 based LockSystem.
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 v2.3.0
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 []prop.PropertyXML }
Proppatch describes a property update instruction as defined in RFC 4918. See http://www.webdav.org/specs/rfc4918.html#METHOD_PROPPATCH
type PublicFileHandler ¶
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 ¶
func (h *PublicFileHandler) Handler(s *svc) http.Handler
Handler handles requests
type SpacesHandler ¶
type SpacesHandler struct {
// contains filtered or unexported fields
}
SpacesHandler handles trashbin requests
func (*SpacesHandler) Handler ¶
func (h *SpacesHandler) Handler(s *svc, trashbinHandler *TrashbinHandler) 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 Validator ¶ added in v2.13.0
Validator validates strings
func ValidatorsFromConfig ¶ added in v2.13.0
ValidatorsFromConfig returns the configured Validators
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 v2.3.0
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 v2.3.0
func (wc *WriteCounter) SendPerfMarker(size uint64)
SendPerfMarker flushes a single chunk (performance marker) as part of the chunked transfer encoding scheme.