Rig up CardDAV backend to HTTP server

References: https://todo.sr.ht/~sircmpwn/tokidoki/3
This commit is contained in:
Simon Ser 2022-02-21 11:39:57 +01:00
parent 13008e0d96
commit 97f86226d6
4 changed files with 50 additions and 3 deletions

View file

@ -6,10 +6,12 @@ import (
"net/http"
"os"
"github.com/emersion/go-webdav/carddav"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"git.sr.ht/~sircmpwn/tokidoki/auth"
"git.sr.ht/~sircmpwn/tokidoki/storage"
)
func main() {
@ -31,9 +33,8 @@ func main() {
authProvider := auth.NewIMAP("imap.migadu.com:993", true)
mux.Use(authProvider.Middleware())
mux.Get("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello world!\n"))
})
backend := storage.NewPostgreSQL()
mux.Handle("/", &carddav.Handler{Backend: backend})
server := http.Server{
Addr: addr,