Esempio n. 1
0
File: web.go Progetto: yubobo/minio
// HTTPHandler - http wrapper handler
func HTTPHandler() http.Handler {
	mux := mux.NewRouter()
	var api = webAPI{}

	if err := api.conf.SetupConfig(); err != nil {
		log.Fatal(iodine.New(err, nil))
	}

	api.webPath = filepath.Join(api.conf.GetConfigPath(), defaultWeb)
	mux.Handle("/{polygon:.*}", http.FileServer(http.Dir(api.webPath))).Methods("GET")
	mux.HandleFunc("/access", api.accessHandler).Methods("POST")
	return mux
}
Esempio n. 2
0
// StartMinio starts minio server
func StartMinio(servers []StartServerFunc) {
	var ctrlChannels []chan<- string
	var errChannels []<-chan error
	for _, server := range servers {
		ctrlChannel, errChannel := server()
		ctrlChannels = append(ctrlChannels, ctrlChannel)
		errChannels = append(errChannels, errChannel)
	}
	cases := createSelectCases(errChannels)
	for len(cases) > 0 {
		chosen, value, recvOk := reflect.Select(cases)
		switch recvOk {
		case true:
			// Status Message Received
			switch true {
			case value.Interface() != nil:
				// For any error received cleanup all existing channels and fail
				for _, ch := range ctrlChannels {
					close(ch)
				}
				msg := fmt.Sprintf("%q", value.Interface())
				log.Fatal(iodine.New(errors.New(msg), nil))
			}
		case false:
			// Channel closed, remove from list
			var aliveStatusChans []<-chan error
			for i, ch := range errChannels {
				if i != chosen {
					aliveStatusChans = append(aliveStatusChans, ch)
				}
			}
			// create new select cases without defunct channel
			errChannels = aliveStatusChans
			cases = createSelectCases(errChannels)
		}
	}
}