diff --git a/routers.go b/routers.go index 8f8e5809c..67bcf4e23 100644 --- a/routers.go +++ b/routers.go @@ -40,8 +40,8 @@ type CloudStorageAPI struct { // WebAPI container for Web API. type WebAPI struct { - // Do not check for incoming authorization header. - Anonymous bool + // FSPath filesystem path. + FSPath string // Once true log all incoming request. AccessLog bool // Minio client instance. @@ -53,9 +53,6 @@ func getWebAPIHandler(web *WebAPI) http.Handler { TimeValidityHandler, // Validate time. CorsHandler, // CORS added only for testing purposes. } - if !web.Anonymous { - mwHandlers = append(mwHandlers, AuthHandler) - } if web.AccessLog { mwHandlers = append(mwHandlers, AccessLogHandler) } @@ -120,7 +117,7 @@ func getNewWebAPI(conf cloudServerConfig) *WebAPI { fatalIf(probe.NewError(e), "Unable to initialize minio client", nil) web := &WebAPI{ - Anonymous: conf.Anonymous, + FSPath: conf.Path, AccessLog: conf.AccessLog, Client: client, } diff --git a/web-definitions.go b/web-definitions.go index 3bc868a83..1e183b67f 100644 --- a/web-definitions.go +++ b/web-definitions.go @@ -23,6 +23,9 @@ type MakeBucketArgs struct { BucketName string `json:"bucketName"` } +// DiskInfoArgs - disk info args. +type DiskInfoArgs struct{} + // ListBucketsArgs - list bucket args. type ListBucketsArgs struct{} diff --git a/web-handlers.go b/web-handlers.go index b6d7fc452..b5f89ddba 100644 --- a/web-handlers.go +++ b/web-handlers.go @@ -22,6 +22,7 @@ import ( "time" jwtgo "github.com/dgrijalva/jwt-go" + "github.com/minio/minio/pkg/disk" ) // isAuthenticated validates if any incoming request to be a valid JWT @@ -40,6 +41,19 @@ func isAuthenticated(req *http.Request) bool { return tokenRequest.Valid } +// DiskInfo - get disk statistics. +func (web *WebAPI) DiskInfo(r *http.Request, args *DiskInfoArgs, reply *disk.Info) error { + if !isAuthenticated(r) { + return errUnAuthorizedRequest + } + info, err := disk.GetInfo(web.FSPath) + if err != nil { + return err + } + *reply = info + return nil +} + // MakeBucket - make a bucket. func (web *WebAPI) MakeBucket(r *http.Request, args *MakeBucketArgs, reply *string) error { if !isAuthenticated(r) {