1

I want to implement a webdav-server with Go and found a new "x" package here:

But I don't know how to use this package to get it done. Can someone help me with this issue?

I tried this:

func main(){
    fs := new(webdav.FileSystem)
    ls := new(webdav.LockSystem)
    h := new(webdav.Handler)
    h.FileSystem = *fs
    h.LockSystem = *ls
    //then use the Handler.ServeHTTP Method as the http.HandleFunc
    http.HandleFunc("/", h.ServeHTTP)
    http.ListenAndServe(":5555", nil)
}

If I try to connect to the server, I get an internal server error.

What am I doing wrong?

Thanks for your help.

Rick-777
  • 9,714
  • 5
  • 34
  • 50
patdhlk
  • 139
  • 3
  • 11

3 Answers3

3

The x/net/webdav is still in early phase of development. Many critical parts are still being implemented, and it can not be used as such at this moment. Taking a look at the source code over half of the necessary structures and functions are still completely missing.

Unfortunately there are no Go based webdav server implementations at this moment. (In case someone can correct me, please feel free to do so!)

user918176
  • 1,770
  • 13
  • 34
  • yes i know that it is in early phase of development...but i read over a codereview (i think thisone: https://codereview.appspot.com/171700045/) and there was mentioned that the developers run a litmus test over it...so i thought that there must be a running server to do the test. it's only for studying not for production use and i am really interested in this package – patdhlk Dec 03 '14 at 18:43
  • @PatrickD. It may "start up" (I managed that after a moment), but it doesn't really do anything yet, let alone give any response a client might recognize. I doubt the mention about litmus test refers to a running "server". – user918176 Dec 03 '14 at 18:52
  • @PatrickD. I could be wrong too, hehe. But hey, you could ask the authors and offer to test what they can manage to produce! They surely can appreciate it. – user918176 Dec 03 '14 at 19:05
  • Yeah...i think i will write an email the next days. We will see what they repeat – patdhlk Dec 03 '14 at 19:12
  • The litmus test pretty much requires a webdav server to be mostly working. – Evert Apr 10 '15 at 18:21
  • One year and a half later, is this answer still valid ? – n00dl3 Jun 10 '16 at 09:42
0
func main(){
    fs := new(webdav.FileSystem)
    ls := new(webdav.LockSystem)
    h := new(webdav.Handler)
    h.FileSystem = fs
    h.LockSystem = ls
    //then use the Handler.ServeHTTP Method as the http.HandleFunc
    http.HandleFunc("/", h.ServeHTTP)
    http.ListenAndServe(":5555", nil)
}

try to remove the * before "fs" and "ls" because they are already pointers. NB : if you have to assign pointer use & and not *

0

Create a webdav server on http://localhost:8080/ which mounts the folder C:\myfiles.

package main

import (
    "net/http"

    "golang.org/x/net/webdav"
)

func main() {
    handler := &webdav.Handler{
        FileSystem: webdav.Dir(`C:\myfiles`),
        LockSystem: webdav.NewMemLS(),
    }

    http.ListenAndServe("localhost:8080", handler)
}

Mount to Letter E: in windows:

net use e: http://localhost:8080/

Open mounted drive in explorer

explorer.exe e:
hdev
  • 6,097
  • 1
  • 45
  • 62