Merge pull request #326 from harshavardhana/pr_out_refactor_to_move_config_handling_into_api
This commit is contained in:
commit
8293c787bf
8 changed files with 21 additions and 21 deletions
|
@ -20,7 +20,7 @@ import (
|
|||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/minio-io/minio/pkg/utils/config"
|
||||
"github.com/minio-io/minio/pkg/api/config"
|
||||
)
|
||||
|
||||
type vHandler struct {
|
||||
|
|
|
@ -20,9 +20,9 @@ import (
|
|||
"log"
|
||||
"net/http"
|
||||
|
||||
x "github.com/gorilla/mux"
|
||||
router "github.com/gorilla/mux"
|
||||
"github.com/minio-io/minio/pkg/api/config"
|
||||
mstorage "github.com/minio-io/minio/pkg/storage"
|
||||
"github.com/minio-io/minio/pkg/utils/config"
|
||||
)
|
||||
|
||||
// private use
|
||||
|
@ -32,7 +32,7 @@ type minioAPI struct {
|
|||
}
|
||||
|
||||
// Path based routing
|
||||
func pathMux(api minioAPI, mux *x.Router) *x.Router {
|
||||
func pathMux(api minioAPI, mux *router.Router) *router.Router {
|
||||
mux.HandleFunc("/", api.listBucketsHandler).Methods("GET")
|
||||
mux.HandleFunc("/{bucket}", api.listObjectsHandler).Methods("GET")
|
||||
mux.HandleFunc("/{bucket}", api.putBucketHandler).Methods("PUT")
|
||||
|
@ -44,7 +44,7 @@ func pathMux(api minioAPI, mux *x.Router) *x.Router {
|
|||
}
|
||||
|
||||
// Domain based routing
|
||||
func domainMux(api minioAPI, mux *x.Router) *x.Router {
|
||||
func domainMux(api minioAPI, mux *router.Router) *router.Router {
|
||||
mux.HandleFunc("/",
|
||||
api.listObjectsHandler).Host("{bucket}" + "." + api.domain).Methods("GET")
|
||||
mux.HandleFunc("/{object:.*}",
|
||||
|
@ -60,7 +60,7 @@ func domainMux(api minioAPI, mux *x.Router) *x.Router {
|
|||
}
|
||||
|
||||
// Get proper router based on domain availability
|
||||
func getMux(api minioAPI, mux *x.Router) *x.Router {
|
||||
func getMux(api minioAPI, mux *router.Router) *router.Router {
|
||||
switch true {
|
||||
case api.domain == "":
|
||||
return pathMux(api, mux)
|
||||
|
@ -73,12 +73,12 @@ func getMux(api minioAPI, mux *x.Router) *x.Router {
|
|||
|
||||
// HTTPHandler - http wrapper handler
|
||||
func HTTPHandler(domain string, storage mstorage.Storage) http.Handler {
|
||||
var mux *x.Router
|
||||
var mux *router.Router
|
||||
var api = minioAPI{}
|
||||
api.storage = storage
|
||||
api.domain = domain
|
||||
|
||||
r := x.NewRouter()
|
||||
r := router.NewRouter()
|
||||
mux = getMux(api, r)
|
||||
|
||||
var conf = config.Config{}
|
||||
|
|
|
@ -18,20 +18,21 @@ package api
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/hmac"
|
||||
"crypto/sha1"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/minio-io/minio/pkg/utils/config"
|
||||
"crypto/hmac"
|
||||
"crypto/sha1"
|
||||
"encoding/base64"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/minio-io/minio/pkg/api/config"
|
||||
)
|
||||
|
||||
// SignRequest - a given http request using HMAC style signatures
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package config_test
|
||||
package config
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
|
@ -23,7 +23,6 @@ import (
|
|||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/minio-io/minio/pkg/utils/config"
|
||||
"github.com/minio-io/minio/pkg/utils/crypto/keys"
|
||||
. "gopkg.in/check.v1"
|
||||
)
|
||||
|
@ -35,7 +34,8 @@ var _ = Suite(&MySuite{})
|
|||
func Test(t *testing.T) { TestingT(t) }
|
||||
|
||||
func (s *MySuite) TestConfig(c *C) {
|
||||
conf := config.Config{}
|
||||
conf := Config{}
|
||||
conf.ConfigLock = new(sync.RWMutex)
|
||||
conf.ConfigPath, _ = ioutil.TempDir("/tmp", "minio-test-")
|
||||
defer os.RemoveAll(conf.ConfigPath)
|
||||
conf.ConfigFile = path.Join(conf.ConfigPath, "config.json")
|
||||
|
@ -45,12 +45,11 @@ func (s *MySuite) TestConfig(c *C) {
|
|||
c.Fatal(err)
|
||||
}
|
||||
}
|
||||
conf.ConfigLock = new(sync.RWMutex)
|
||||
|
||||
accesskey, _ := keys.GenerateRandomAlphaNumeric(keys.MinioAccessID)
|
||||
secretkey, _ := keys.GenerateRandomBase64(keys.MinioSecretID)
|
||||
|
||||
user := config.User{
|
||||
user := User{
|
||||
Name: "gnubot",
|
||||
AccessKey: string(accesskey),
|
||||
SecretKey: string(secretkey),
|
||||
|
@ -65,7 +64,7 @@ func (s *MySuite) TestConfig(c *C) {
|
|||
|
||||
accesskey, _ = keys.GenerateRandomAlphaNumeric(keys.MinioAccessID)
|
||||
secretkey, _ = keys.GenerateRandomBase64(keys.MinioSecretID)
|
||||
user = config.User{
|
||||
user = User{
|
||||
Name: "minio",
|
||||
AccessKey: string(accesskey),
|
||||
SecretKey: string(secretkey),
|
|
@ -24,7 +24,7 @@ import (
|
|||
"path"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/minio-io/minio/pkg/utils/config"
|
||||
"github.com/minio-io/minio/pkg/api/config"
|
||||
"github.com/minio-io/minio/pkg/utils/crypto/keys"
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue