package application import ( "net/http" "fmt" "log" "io" "caj-larsson/bog/domain" "caj-larsson/bog/integration" ) type Bog struct { config *Configuration mux *http.ServeMux // file_service *domain.BogFileService fileDataRepo domain.FileDataRepository } func New(config *Configuration) *Bog { b := new(Bog) b.config = config log.Print(config) fsBogRepo := new(integration.FileSystemBogRepository) fsBogRepo.Root = "/tmp/datta" b.fileDataRepo = *fsBogRepo // uaRepo *domain.UserAgentRepository b.mux = http.NewServeMux() b.mux.HandleFunc("/",func(w http.ResponseWriter, r *http.Request) { if r.URL.Path == "/" { fmt.Fprintf(w, "Hi") return } bog_file, err := b.fileDataRepo.OpenOrCreate(r.URL.Path, r.Header["User-Agent"][0]) if err != nil { } switch r.Method { case "GET": src := domainFileSource { bog_file.Path(), http.ServeContent(w, r, , bog_file.Modified(), bog_file) case "POST": fallthrough case "PUT": io.Copy(bog_file, r.Body) bog_file.Close() } return }) return b } func (b *Bog) Run() { http.ListenAndServe(b.config.address(), b.mux) } func CreateFileHandler(w http.ResponseWriter, r *http.Request) { }