Webdav Server in Go

一曲冷凌霜 提交于 2019-12-08 04:13:11

问题


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.


回答1:


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!)




回答2:


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 *



来源:https://stackoverflow.com/questions/27278501/webdav-server-in-go

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!