dave/cmd/swd/main.go

41 lines
843 B
Go
Raw Normal View History

package main
import (
2018-04-09 14:12:54 +02:00
"fmt"
2018-04-09 15:27:21 +02:00
"github.com/micromata/swd/app"
"golang.org/x/net/webdav"
"log"
2018-04-09 15:27:21 +02:00
"net/http"
)
func main() {
2018-04-09 14:12:54 +02:00
config := app.ParseConfig()
wdHandler := &webdav.Handler{
Prefix: config.Prefix,
FileSystem: &app.Dir{
Config: config,
},
LockSystem: webdav.NewMemLS(),
}
//wdHandler.Logger = app.ModificationLogHandler
a := &app.App{
Config: config,
Handler: wdHandler,
}
http.Handle("/", app.NewBasicAuthWebdavHandler(a))
2018-04-09 14:12:54 +02:00
connAddr := fmt.Sprintf("%s:%s", config.Address, config.Port)
if config.TLS != nil {
fmt.Printf("TLS Server is starting and listening at: %s\n", connAddr)
log.Fatal(http.ListenAndServeTLS(connAddr, config.TLS.CertFile, config.TLS.KeyFile, nil))
} else {
fmt.Printf("Server is starting and listening at: %s\n", connAddr)
log.Fatal(http.ListenAndServe(connAddr, nil))
}
}