Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add WebDAV support(#1610) #2173

Closed
wants to merge 2 commits into from
Closed

add WebDAV support(#1610) #2173

wants to merge 2 commits into from

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 youzhilane01@gmail.com

Signed-off-by: yixy <youzhilane01@gmail.com>
@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 <youzhilane01@gmail.com>
@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