mirror of
https://git.sr.ht/~sircmpwn/tokidoki
synced 2025-12-12 14:17:21 +01:00
Make storage backend configurable via -storage.url
Same mechanism as for configuring the auth backend.
This commit is contained in:
parent
3e464747d8
commit
edd01ff7a3
2 changed files with 31 additions and 7 deletions
24
storage/url.go
Normal file
24
storage/url.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package storage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"github.com/emersion/go-webdav/carddav"
|
||||
)
|
||||
|
||||
func NewFromURL(storageURL string) (carddav.Backend, error) {
|
||||
u, err := url.Parse(storageURL)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error parsing storage URL: %s", err.Error())
|
||||
}
|
||||
|
||||
switch u.Scheme {
|
||||
case "file":
|
||||
return NewFilesystem(u.Path)
|
||||
case "postgresql":
|
||||
return NewPostgreSQL(), nil
|
||||
default:
|
||||
return nil, fmt.Errorf("no storage provider found for %s:// URL", u.Scheme)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue