mirror of
https://github.com/1f349/go-webdav.git
synced 2025-01-11 09:56:28 +00:00
internal: move Depth to internal.go
This commit is contained in:
parent
90fe8dedf7
commit
c0a91b0085
@ -10,47 +10,6 @@ import (
|
||||
"path"
|
||||
)
|
||||
|
||||
// Depth indicates whether a request applies to the resource's members. It's
|
||||
// defined in RFC 4918 section 10.2.
|
||||
type Depth int
|
||||
|
||||
const (
|
||||
// DepthZero indicates that the request applies only to the resource.
|
||||
DepthZero Depth = 0
|
||||
// DepthOne indicates that the request applies to the resource and its
|
||||
// internal members only.
|
||||
DepthOne Depth = 1
|
||||
// DepthInfinity indicates that the request applies to the resource and all
|
||||
// of its members.
|
||||
DepthInfinity Depth = -1
|
||||
)
|
||||
|
||||
// ParseDepth parses a Depth header.
|
||||
func ParseDepth(s string) (Depth, error) {
|
||||
switch s {
|
||||
case "0":
|
||||
return DepthZero, nil
|
||||
case "1":
|
||||
return DepthOne, nil
|
||||
case "infinity":
|
||||
return DepthInfinity, nil
|
||||
}
|
||||
return 0, fmt.Errorf("webdav: invalid Depth value")
|
||||
}
|
||||
|
||||
// String formats the depth.
|
||||
func (d Depth) String() string {
|
||||
switch d {
|
||||
case DepthZero:
|
||||
return "0"
|
||||
case DepthOne:
|
||||
return "1"
|
||||
case DepthInfinity:
|
||||
return "infinity"
|
||||
}
|
||||
panic("webdav: invalid Depth value")
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
http *http.Client
|
||||
endpoint *url.URL
|
||||
|
47
internal/internal.go
Normal file
47
internal/internal.go
Normal file
@ -0,0 +1,47 @@
|
||||
// Package internal provides low-level helpers for WebDAV clients and servers.
|
||||
package internal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Depth indicates whether a request applies to the resource's members. It's
|
||||
// defined in RFC 4918 section 10.2.
|
||||
type Depth int
|
||||
|
||||
const (
|
||||
// DepthZero indicates that the request applies only to the resource.
|
||||
DepthZero Depth = 0
|
||||
// DepthOne indicates that the request applies to the resource and its
|
||||
// internal members only.
|
||||
DepthOne Depth = 1
|
||||
// DepthInfinity indicates that the request applies to the resource and all
|
||||
// of its members.
|
||||
DepthInfinity Depth = -1
|
||||
)
|
||||
|
||||
// ParseDepth parses a Depth header.
|
||||
func ParseDepth(s string) (Depth, error) {
|
||||
switch s {
|
||||
case "0":
|
||||
return DepthZero, nil
|
||||
case "1":
|
||||
return DepthOne, nil
|
||||
case "infinity":
|
||||
return DepthInfinity, nil
|
||||
}
|
||||
return 0, fmt.Errorf("webdav: invalid Depth value")
|
||||
}
|
||||
|
||||
// String formats the depth.
|
||||
func (d Depth) String() string {
|
||||
switch d {
|
||||
case DepthZero:
|
||||
return "0"
|
||||
case DepthOne:
|
||||
return "1"
|
||||
case DepthInfinity:
|
||||
return "infinity"
|
||||
}
|
||||
panic("webdav: invalid Depth value")
|
||||
}
|
Loading…
Reference in New Issue
Block a user