lib

package
v4.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2023 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const MIMEDefault = "application/octet-stream"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	*User
	Auth    bool
	NoSniff bool
	Cors    CorsCfg
	Users   map[string]*User
}

Config is the configuration of a WebDAV instance.

func (*Config) ServeHTTP

func (c *Config) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP determines if the request is for this plugin, and if all prerequisites are met.

type CorsCfg

type CorsCfg struct {
	Enabled        bool
	Credentials    bool
	AllowedHeaders []string
	AllowedHosts   []string
	AllowedMethods []string
	ExposedHeaders []string
}

CorsCfg is the CORS config.

type FS added in v4.1.2

type FS struct {
	Scope   string
	FS      FSGenerator
	Options map[string]string
}

func (FS) Mkdir added in v4.1.2

func (f FS) Mkdir(ctx context.Context, name string, perm os.FileMode) (err error)

func (FS) OpenFile added in v4.1.2

func (f FS) OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (file webdav.File, err error)

func (FS) RemoveAll added in v4.1.2

func (f FS) RemoveAll(ctx context.Context, name string) (err error)

func (FS) Rename added in v4.1.2

func (f FS) Rename(ctx context.Context, oldName, newName string) (err error)

func (FS) Stat added in v4.1.2

func (f FS) Stat(ctx context.Context, name string) (fi os.FileInfo, err error)

type FSGenerator added in v4.1.2

type FSGenerator func(scope string, options map[string]string) webdav.FileSystem

type NoSniffFileInfo

type NoSniffFileInfo struct {
	os.FileInfo
}

NoSniffFileInfo wraps any generic FileInfo interface and bypasses mime type sniffing.

func (NoSniffFileInfo) ContentType

func (w NoSniffFileInfo) ContentType(ctx context.Context) (contentType string, err error)

type Rule

type Rule struct {
	Regex  bool
	Allow  bool
	Modify bool
	Path   string
	Regexp *regexp.Regexp
}

Rule is a dissalow/allow rule.

type User

type User struct {
	Username string
	Password string
	Scope    string
	Modify   bool
	Rules    []*Rule
	Handler  *webdav.Handler
}

User contains the settings of each user.

func (User) Allowed

func (u User) Allowed(url string, noModification bool) bool

Allowed checks if the user has permission to access a directory/file

type WebDavDir

type WebDavDir struct {
	webdav.Dir
	User    *User
	NoSniff bool
}

func (WebDavDir) OpenFile

func (d WebDavDir) OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (webdav.File, error)

func (WebDavDir) Stat

func (d WebDavDir) Stat(ctx context.Context, name string) (os.FileInfo, error)

type WebDavFS added in v4.1.2

type WebDavFS struct {
	FS
	User    *User
	NoSniff bool
}

func (WebDavFS) OpenFile added in v4.1.2

func (d WebDavFS) OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (webdav.File, error)

func (WebDavFS) Stat added in v4.1.2

func (d WebDavFS) Stat(ctx context.Context, name string) (os.FileInfo, error)

type WebDavFile

type WebDavFile struct {
	webdav.File
}

func (WebDavFile) Readdir

func (f WebDavFile) Readdir(count int) (fis []os.FileInfo, err error)

func (WebDavFile) Stat

func (f WebDavFile) Stat() (os.FileInfo, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL