Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

yixy
Copy link

@yixy yixy commented May 4, 2022

#1610

WebDAV support by adding method : MKCOL,COPY ,MOVE ,LOCK,UNLOCK, PROPPATCH, no dependencies added.

Working code using echo & golang.org/x/net/webdav

package main

import (
	"flag"
	"fmt"
	"os"

	"github.com/labstack/echo/v4"
	"golang.org/x/net/webdav"
)

var (
	flagRootDir  = flag.String("dir", "", "webdav root dir")
	flagHttpAddr = flag.String("http", ":8080", "http or https address")
)

func init() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage of WebDAV Server\n")
		flag.PrintDefaults()
	}
}
func main() {
	flag.Parse()
	fs := &webdav.Handler{
		FileSystem: webdav.Dir(*flagRootDir),
		LockSystem: webdav.NewMemLS(),
	}

	e := echo.New()
	e.Pre(func(next echo.HandlerFunc) echo.HandlerFunc {
		return func(c echo.Context) error {
			fmt.Println(c.Request())
			return next(c)
		}
	})
	echoHandle := echo.WrapHandler(fs)
	e.Any("/*", echoHandle)
	fmt.Println(e.Start(*flagHttpAddr))
}

Signed-off-by: yixy [email protected]

@aldas
Copy link
Contributor

aldas commented May 4, 2022

Note to self:

I think we should port v5 way of handling arbitrary methods to v4. See how routeMethods.anyOther is handled

echo/router.go

Line 224 in ed2888c

anyOther map[string]*routeMethod

Signed-off-by: yixy <[email protected]>
@yixy
Copy link
Author

yixy commented May 4, 2022

Note to self:

I think we should port v5 way of handling arbitrary methods to v4. See how routeMethods.anyOther is handled

echo/router.go

Line 224 in ed2888c

anyOther map[string]*routeMethod

I tried using code in v5_alpha, WebDAV seems not supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants