aboutsummaryrefslogblamecommitdiff
path: root/main.go
blob: cd68a4696d81b0b998069cf656fd6a6bbe7eb4e1 (plain) (tree)
1
2
3
4
5
6
7
8
9


            
             
                  

 
             
                                              



















                                                                    
                  
 
                                                                           


                                                               
package main

import (
	"log"
	"net/http"
)

func main() {
	log.Println("=== Starting Bagage ===")
	config := (&Config{}).LoadWithDefault().LoadWithEnv()

	log.Println(config)

	// Assemble components to handle WebDAV requests
	http.Handle(config.DavPath+"/",
		BasicAuthExtract{
			OnNotFound: NotAuthorized{},
			OnCreds: LdapPreAuth{
				WithConfig:      config,
				OnWrongPassword: NotAuthorized{},
				OnFailure:       InternalError{},
				OnCreds: S3Auth{
					WithConfig: config,
					OnFailure:  InternalError{},
					OnMinioClient: WebDav{
						WithConfig: config,
					},
				},
			},
		})

	if err := http.ListenAndServe(config.HttpListen, nil); err != nil {
		log.Fatalf("Error with WebDAV server: %v", err)
	}
}