From d3d1c1afb3e9c07776c2e442d2211f71be13c4e3 Mon Sep 17 00:00:00 2001 From: "Frederick F. Kautz IV" Date: Sun, 18 Jan 2015 15:50:53 -0800 Subject: [PATCH] Minor refactoring, moving http request logic from storage to server --- pkg/server/server.go | 17 +++++++++++++++-- pkg/storage/storage.go | 18 +----------------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/pkg/server/server.go b/pkg/server/server.go index 4387acafa..7f926dc79 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -1,9 +1,12 @@ package server import ( + "io" "log" + "net/http" "reflect" + "github.com/gorilla/mux" "github.com/minio-io/minio/pkg/httpserver" "github.com/minio-io/minio/pkg/storage" ) @@ -16,7 +19,7 @@ func Start() { ctrlChans = append(ctrlChans, ctrlChan) statusChans = append(statusChans, statusChan) - ctrlChan, statusChan = httpserver.Start(storage.GetHttpHandler()) + ctrlChan, statusChan = httpserver.Start(getHttpHandler()) ctrlChans = append(ctrlChans, ctrlChan) statusChans = append(statusChans, statusChan) @@ -35,10 +38,10 @@ func Start() { aliveStatusChans = append(aliveStatusChans, ch) } } + // create new select cases without defunct channel statusChans = aliveStatusChans cases = createSelectCases(statusChans) } - // create new select case } } @@ -52,3 +55,13 @@ func createSelectCases(channels []<-chan error) []reflect.SelectCase { } return cases } + +func getHttpHandler() http.Handler { + mux := mux.NewRouter() + mux.HandleFunc("/", storageHandler) + return mux +} + +func storageHandler(w http.ResponseWriter, req *http.Request) { + io.WriteString(w, "MINIO") +} diff --git a/pkg/storage/storage.go b/pkg/storage/storage.go index 27b8da36e..7e212a6fa 100644 --- a/pkg/storage/storage.go +++ b/pkg/storage/storage.go @@ -1,22 +1,6 @@ package storage -import ( - "errors" - "io" - "net/http" - - "github.com/gorilla/mux" -) - -func GetHttpHandler() http.Handler { - mux := mux.NewRouter() - mux.HandleFunc("/", storageHandler) - return mux -} - -func storageHandler(w http.ResponseWriter, req *http.Request) { - io.WriteString(w, "MINIO") -} +import "errors" func Start() (chan<- string, <-chan error) { ctrlChannel := make(chan string)