diskInfo: Add DiskInfo API

master
Harshavardhana 9 years ago
parent 1341fb79c3
commit 13feabefd5
  1. 9
      routers.go
  2. 3
      web-definitions.go
  3. 14
      web-handlers.go

@ -40,8 +40,8 @@ type CloudStorageAPI struct {
// WebAPI container for Web API. // WebAPI container for Web API.
type WebAPI struct { type WebAPI struct {
// Do not check for incoming authorization header. // FSPath filesystem path.
Anonymous bool FSPath string
// Once true log all incoming request. // Once true log all incoming request.
AccessLog bool AccessLog bool
// Minio client instance. // Minio client instance.
@ -53,9 +53,6 @@ func getWebAPIHandler(web *WebAPI) http.Handler {
TimeValidityHandler, // Validate time. TimeValidityHandler, // Validate time.
CorsHandler, // CORS added only for testing purposes. CorsHandler, // CORS added only for testing purposes.
} }
if !web.Anonymous {
mwHandlers = append(mwHandlers, AuthHandler)
}
if web.AccessLog { if web.AccessLog {
mwHandlers = append(mwHandlers, AccessLogHandler) mwHandlers = append(mwHandlers, AccessLogHandler)
} }
@ -120,7 +117,7 @@ func getNewWebAPI(conf cloudServerConfig) *WebAPI {
fatalIf(probe.NewError(e), "Unable to initialize minio client", nil) fatalIf(probe.NewError(e), "Unable to initialize minio client", nil)
web := &WebAPI{ web := &WebAPI{
Anonymous: conf.Anonymous, FSPath: conf.Path,
AccessLog: conf.AccessLog, AccessLog: conf.AccessLog,
Client: client, Client: client,
} }

@ -23,6 +23,9 @@ type MakeBucketArgs struct {
BucketName string `json:"bucketName"` BucketName string `json:"bucketName"`
} }
// DiskInfoArgs - disk info args.
type DiskInfoArgs struct{}
// ListBucketsArgs - list bucket args. // ListBucketsArgs - list bucket args.
type ListBucketsArgs struct{} type ListBucketsArgs struct{}

@ -22,6 +22,7 @@ import (
"time" "time"
jwtgo "github.com/dgrijalva/jwt-go" jwtgo "github.com/dgrijalva/jwt-go"
"github.com/minio/minio/pkg/disk"
) )
// isAuthenticated validates if any incoming request to be a valid JWT // isAuthenticated validates if any incoming request to be a valid JWT
@ -40,6 +41,19 @@ func isAuthenticated(req *http.Request) bool {
return tokenRequest.Valid 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. // MakeBucket - make a bucket.
func (web *WebAPI) MakeBucket(r *http.Request, args *MakeBucketArgs, reply *string) error { func (web *WebAPI) MakeBucket(r *http.Request, args *MakeBucketArgs, reply *string) error {
if !isAuthenticated(r) { if !isAuthenticated(r) {

Loading…
Cancel
Save