Make Media Storage optional

master
Jan-Lukas Else 2020-01-12 17:48:05 +01:00
parent f71738cde4
commit 1c3cc6480f
2 changed files with 8 additions and 3 deletions

View File

@ -74,7 +74,7 @@ func initConfig() (err error) {
if SelectedStorage == nil {
return errors.New("no storage configured")
}
// Find selected media storage
// Find selected media storage (Optional)
SelectedMediaStorage = func() MediaStorage {
// BunnyCDN
if len(cfg.BunnyCdnStorageKey) > 0 && len(cfg.BunnyCdnStorageName) > 0 && len(cfg.MediaUrl) > 0 {
@ -87,11 +87,11 @@ func initConfig() (err error) {
return nil
}()
if SelectedMediaStorage == nil {
return errors.New("no media storage configured")
log.Println("no media storage configured")
}
// Find selected CDN (optional)
SelectedCdn = func() Cdn {
// BunnyCDN (optional)
// BunnyCDN
if len(cfg.BunnyCdnKey) > 0 {
return &BunnyCdn{key: cfg.BunnyCdnKey}
}

View File

@ -11,6 +11,11 @@ import (
)
func HandleMedia(w http.ResponseWriter, r *http.Request) {
if SelectedMediaStorage == nil {
w.WriteHeader(http.StatusInternalServerError)
_, _ = w.Write([]byte("No media storage configured"))
return
}
if r.Method != "POST" {
w.WriteHeader(http.StatusMethodNotAllowed)
_, _ = w.Write([]byte("The HTTP method is not allowed, make a POST request"))