kataras / kataras/iris

Proper way to implement WebDAV server

Open
#1,866 25 comments 0 reactions 0 assignees View on GitHub
🤔 type:question
Dominant language
Go
Stars
25.6k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Hi,

I'm trying to implement WebDAV server with iris but I can not figure it out. I've checked some older closed issues but it's not working properly. I can connect directory but it's not allowing me to access or change any file. Here is some sample. If you replace iris with standard http it works properly;

```go
package main

import (
"log"
"net/http"

"github.com/kataras/iris/v12"
routing "github.com/kataras/iris/v12/core/router"
"github.com/kataras/iris/v12/middleware/logger"
"github.com/kataras/iris/v12/middleware/recover"
"golang.org/x/net/webdav"
)

func init() {
myCustomMethods := []string{"COPY",
"LINK",
"UNLINK",
"PURGE",
"LOCK",
"UNLOCK",
"PROPFIND",
"VIEW",
}

routing.AllMethods = append(routing.AllMethods, myCustomMethods...)
}

func main() {
webdavHandler := &webdav.Handler{
FileSystem: webdav.Dir("./"),
LockSystem: webdav.NewMemLS(),
Logger: func(r *http.Request, err error) {
if err != nil {
log.Printf("ERROR: %v", err)
}
},
}

// Proper working server
// http.Handle("/", webdavHandler)
// if err := http.ListenAndServe(":8080", nil); err != nil {
// log.Fatalf("Error with WebDAV server: %v", err)
// }

app := iris.New()
app.Logger().SetLevel("debug")
app.Use(recover.New())
app.Use(logger.New())

app.Any("/", iris.FromStd(webdavHandler))

app.Run(
iris.Addr(":8080"),
iris.WithoutServerError(iris.ErrServerClosed),
)
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.