2015-06-30 23:15:48 -04:00
|
|
|
/*
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-12 18:27:10 -05:00
|
|
|
* Minio Cloud Storage, (C) 2015, 2016 Minio, Inc.
|
2015-06-30 23:15:48 -04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2015-09-19 03:52:01 -04:00
|
|
|
package main
|
2015-06-30 23:15:48 -04:00
|
|
|
|
|
|
|
import (
|
2016-03-03 19:39:19 -05:00
|
|
|
"fmt"
|
2016-01-25 01:26:53 -05:00
|
|
|
"net"
|
2015-06-30 23:15:48 -04:00
|
|
|
"net/http"
|
|
|
|
|
2016-02-23 16:05:47 -05:00
|
|
|
"github.com/elazarl/go-bindata-assetfs"
|
2016-03-03 21:15:56 -05:00
|
|
|
"github.com/gorilla/handlers"
|
2015-08-22 21:34:00 -04:00
|
|
|
router "github.com/gorilla/mux"
|
2016-01-23 22:44:32 -05:00
|
|
|
jsonrpc "github.com/gorilla/rpc/v2"
|
2016-02-11 13:11:43 -05:00
|
|
|
"github.com/gorilla/rpc/v2/json2"
|
2016-01-25 01:26:53 -05:00
|
|
|
"github.com/minio/minio-go"
|
2015-10-16 14:26:01 -04:00
|
|
|
"github.com/minio/minio/pkg/fs"
|
2016-02-10 19:40:09 -05:00
|
|
|
"github.com/minio/minio/pkg/probe"
|
2016-02-23 16:05:47 -05:00
|
|
|
"github.com/minio/miniobrowser"
|
2015-06-30 23:15:48 -04:00
|
|
|
)
|
|
|
|
|
2016-02-18 05:13:52 -05:00
|
|
|
// storageAPI container for S3 compatible API.
|
|
|
|
type storageAPI struct {
|
2016-01-25 01:26:53 -05:00
|
|
|
// Filesystem instance.
|
2015-10-19 15:15:19 -04:00
|
|
|
Filesystem fs.Filesystem
|
|
|
|
}
|
|
|
|
|
2016-02-18 05:13:52 -05:00
|
|
|
// webAPI container for Web API.
|
|
|
|
type webAPI struct {
|
2016-01-26 15:08:45 -05:00
|
|
|
// FSPath filesystem path.
|
|
|
|
FSPath string
|
2016-01-25 01:26:53 -05:00
|
|
|
// Minio client instance.
|
2016-03-10 17:22:28 -05:00
|
|
|
Client *minio.Client
|
2016-01-27 04:52:54 -05:00
|
|
|
|
|
|
|
// private params.
|
|
|
|
apiAddress string // api destination address.
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-12 18:27:10 -05:00
|
|
|
// credential kept to be used internally.
|
2016-01-27 04:52:54 -05:00
|
|
|
accessKeyID string
|
|
|
|
secretAccessKey string
|
2016-01-21 19:28:15 -05:00
|
|
|
}
|
|
|
|
|
2016-02-23 13:37:27 -05:00
|
|
|
// indexHandler - Handler to serve index.html
|
|
|
|
type indexHandler struct {
|
|
|
|
handler http.Handler
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h indexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
|
|
r.URL.Path = privateBucket + "/"
|
|
|
|
h.handler.ServeHTTP(w, r)
|
|
|
|
}
|
|
|
|
|
2016-02-23 16:05:47 -05:00
|
|
|
const assetPrefix = "production"
|
|
|
|
|
|
|
|
func assetFS() *assetfs.AssetFS {
|
|
|
|
return &assetfs.AssetFS{
|
|
|
|
Asset: miniobrowser.Asset,
|
|
|
|
AssetDir: miniobrowser.AssetDir,
|
|
|
|
AssetInfo: miniobrowser.AssetInfo,
|
|
|
|
Prefix: assetPrefix,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-03 19:39:19 -05:00
|
|
|
// specialAssets are files which are unique files not embedded inside index_bundle.js.
|
|
|
|
const specialAssets = "loader.css|logo.svg|firefox.png|safari.png|chrome.png|favicon.ico"
|
|
|
|
|
2016-02-18 05:13:52 -05:00
|
|
|
// registerAPIHandlers - register all the handlers to their respective paths
|
|
|
|
func registerAPIHandlers(mux *router.Router, a storageAPI, w *webAPI) {
|
2016-02-16 21:50:36 -05:00
|
|
|
// Minio rpc router
|
|
|
|
minio := mux.NewRoute().PathPrefix(privateBucket).Subrouter()
|
2016-01-23 22:44:32 -05:00
|
|
|
|
2016-02-16 21:50:36 -05:00
|
|
|
// Initialize json rpc handlers.
|
|
|
|
rpc := jsonrpc.NewServer()
|
2016-02-11 13:11:43 -05:00
|
|
|
codec := json2.NewCodec()
|
2016-02-16 21:50:36 -05:00
|
|
|
rpc.RegisterCodec(codec, "application/json")
|
|
|
|
rpc.RegisterCodec(codec, "application/json; charset=UTF-8")
|
|
|
|
rpc.RegisterService(w, "Web")
|
2016-01-30 21:33:33 -05:00
|
|
|
|
2016-02-16 21:50:36 -05:00
|
|
|
// RPC handler at URI - /minio/rpc
|
|
|
|
minio.Path("/rpc").Handler(rpc)
|
2016-03-03 19:39:19 -05:00
|
|
|
// Serve all assets.
|
2016-03-03 21:15:56 -05:00
|
|
|
minio.Path(fmt.Sprintf("/{assets:[^/]+.js|%s}", specialAssets)).Handler(handlers.CompressHandler(http.StripPrefix(privateBucket, http.FileServer(assetFS()))))
|
2016-02-23 13:37:27 -05:00
|
|
|
// Serve index.html for rest of the requests
|
|
|
|
minio.Path("/{index:.*}").Handler(indexHandler{http.StripPrefix(privateBucket, http.FileServer(assetFS()))})
|
2016-02-16 21:50:36 -05:00
|
|
|
|
|
|
|
// API Router
|
|
|
|
api := mux.NewRoute().PathPrefix("/").Subrouter()
|
2016-01-21 19:28:15 -05:00
|
|
|
|
2015-11-07 17:15:22 -05:00
|
|
|
// Bucket router
|
2016-02-16 21:50:36 -05:00
|
|
|
bucket := api.PathPrefix("/{bucket}").Subrouter()
|
2015-06-30 23:15:48 -04:00
|
|
|
|
2016-02-27 06:04:52 -05:00
|
|
|
/// Object operations
|
|
|
|
|
|
|
|
// HeadObject
|
2015-10-25 11:00:39 -04:00
|
|
|
bucket.Methods("HEAD").Path("/{object:.+}").HandlerFunc(a.HeadObjectHandler)
|
2016-02-27 06:04:52 -05:00
|
|
|
// PutObjectPart
|
2015-10-25 11:00:39 -04:00
|
|
|
bucket.Methods("PUT").Path("/{object:.+}").HandlerFunc(a.PutObjectPartHandler).Queries("partNumber", "{partNumber:[0-9]+}", "uploadId", "{uploadId:.*}")
|
2016-02-27 06:04:52 -05:00
|
|
|
// ListObjectPxarts
|
2015-10-25 11:00:39 -04:00
|
|
|
bucket.Methods("GET").Path("/{object:.+}").HandlerFunc(a.ListObjectPartsHandler).Queries("uploadId", "{uploadId:.*}")
|
2016-02-27 06:04:52 -05:00
|
|
|
// CompleteMultipartUpload
|
2015-10-25 11:00:39 -04:00
|
|
|
bucket.Methods("POST").Path("/{object:.+}").HandlerFunc(a.CompleteMultipartUploadHandler).Queries("uploadId", "{uploadId:.*}")
|
2016-02-27 06:04:52 -05:00
|
|
|
// NewMultipartUpload
|
2015-10-25 11:00:39 -04:00
|
|
|
bucket.Methods("POST").Path("/{object:.+}").HandlerFunc(a.NewMultipartUploadHandler).Queries("uploads", "")
|
2016-02-27 06:04:52 -05:00
|
|
|
// AbortMultipartUpload
|
2015-10-25 11:00:39 -04:00
|
|
|
bucket.Methods("DELETE").Path("/{object:.+}").HandlerFunc(a.AbortMultipartUploadHandler).Queries("uploadId", "{uploadId:.*}")
|
2016-02-27 06:04:52 -05:00
|
|
|
// GetObject
|
2015-10-25 11:00:39 -04:00
|
|
|
bucket.Methods("GET").Path("/{object:.+}").HandlerFunc(a.GetObjectHandler)
|
2016-02-27 06:04:52 -05:00
|
|
|
// CopyObject
|
|
|
|
bucket.Methods("PUT").Path("/{object:.+}").HeadersRegexp("X-Amz-Copy-Source", ".*?(\\/).*?").HandlerFunc(a.CopyObjectHandler)
|
|
|
|
// PutObject
|
2015-10-25 11:00:39 -04:00
|
|
|
bucket.Methods("PUT").Path("/{object:.+}").HandlerFunc(a.PutObjectHandler)
|
2016-02-27 06:04:52 -05:00
|
|
|
// DeleteObject
|
2015-10-25 11:00:39 -04:00
|
|
|
bucket.Methods("DELETE").Path("/{object:.+}").HandlerFunc(a.DeleteObjectHandler)
|
|
|
|
|
2016-02-27 06:04:52 -05:00
|
|
|
/// Bucket operations
|
|
|
|
|
|
|
|
// GetBucketLocation
|
2015-12-27 02:38:38 -05:00
|
|
|
bucket.Methods("GET").HandlerFunc(a.GetBucketLocationHandler).Queries("location", "")
|
accessPolicy: Implement Put, Get, Delete access policy.
This patch implements Get,Put,Delete bucket policies
Supporting - http://docs.aws.amazon.com/AmazonS3/latest/dev/access-policy-language-overview.html
Currently supports following actions.
"*": true,
"s3:*": true,
"s3:GetObject": true,
"s3:ListBucket": true,
"s3:PutObject": true,
"s3:CreateBucket": true,
"s3:GetBucketLocation": true,
"s3:DeleteBucket": true,
"s3:DeleteObject": true,
"s3:AbortMultipartUpload": true,
"s3:ListBucketMultipartUploads": true,
"s3:ListMultipartUploadParts": true,
following conditions for "StringEquals" and "StringNotEquals"
"s3:prefix", "s3:max-keys"
2016-02-03 19:46:56 -05:00
|
|
|
// GetBucketPolicy
|
|
|
|
bucket.Methods("GET").HandlerFunc(a.GetBucketPolicyHandler).Queries("policy", "")
|
2016-02-27 06:04:52 -05:00
|
|
|
// ListMultipartUploads
|
2015-10-25 11:00:39 -04:00
|
|
|
bucket.Methods("GET").HandlerFunc(a.ListMultipartUploadsHandler).Queries("uploads", "")
|
2016-02-27 06:04:52 -05:00
|
|
|
// ListObjects
|
2015-10-25 11:00:39 -04:00
|
|
|
bucket.Methods("GET").HandlerFunc(a.ListObjectsHandler)
|
accessPolicy: Implement Put, Get, Delete access policy.
This patch implements Get,Put,Delete bucket policies
Supporting - http://docs.aws.amazon.com/AmazonS3/latest/dev/access-policy-language-overview.html
Currently supports following actions.
"*": true,
"s3:*": true,
"s3:GetObject": true,
"s3:ListBucket": true,
"s3:PutObject": true,
"s3:CreateBucket": true,
"s3:GetBucketLocation": true,
"s3:DeleteBucket": true,
"s3:DeleteObject": true,
"s3:AbortMultipartUpload": true,
"s3:ListBucketMultipartUploads": true,
"s3:ListMultipartUploadParts": true,
following conditions for "StringEquals" and "StringNotEquals"
"s3:prefix", "s3:max-keys"
2016-02-03 19:46:56 -05:00
|
|
|
// PutBucketPolicy
|
|
|
|
bucket.Methods("PUT").HandlerFunc(a.PutBucketPolicyHandler).Queries("policy", "")
|
2016-02-27 06:04:52 -05:00
|
|
|
// PutBucket
|
2015-10-25 11:00:39 -04:00
|
|
|
bucket.Methods("PUT").HandlerFunc(a.PutBucketHandler)
|
2016-02-27 06:04:52 -05:00
|
|
|
// HeadBucket
|
2015-10-25 11:00:39 -04:00
|
|
|
bucket.Methods("HEAD").HandlerFunc(a.HeadBucketHandler)
|
2016-03-22 20:54:31 -04:00
|
|
|
// PostPolicy
|
|
|
|
bucket.Methods("POST").HeadersRegexp("Content-Type", "multipart/form-data*").HandlerFunc(a.PostPolicyBucketHandler)
|
2016-03-05 19:43:48 -05:00
|
|
|
// DeleteMultipleObjects
|
|
|
|
bucket.Methods("POST").HandlerFunc(a.DeleteMultipleObjectsHandler)
|
accessPolicy: Implement Put, Get, Delete access policy.
This patch implements Get,Put,Delete bucket policies
Supporting - http://docs.aws.amazon.com/AmazonS3/latest/dev/access-policy-language-overview.html
Currently supports following actions.
"*": true,
"s3:*": true,
"s3:GetObject": true,
"s3:ListBucket": true,
"s3:PutObject": true,
"s3:CreateBucket": true,
"s3:GetBucketLocation": true,
"s3:DeleteBucket": true,
"s3:DeleteObject": true,
"s3:AbortMultipartUpload": true,
"s3:ListBucketMultipartUploads": true,
"s3:ListMultipartUploadParts": true,
following conditions for "StringEquals" and "StringNotEquals"
"s3:prefix", "s3:max-keys"
2016-02-03 19:46:56 -05:00
|
|
|
// DeleteBucketPolicy
|
|
|
|
bucket.Methods("DELETE").HandlerFunc(a.DeleteBucketPolicyHandler).Queries("policy", "")
|
2016-02-27 06:04:52 -05:00
|
|
|
// DeleteBucket
|
2015-10-25 11:00:39 -04:00
|
|
|
bucket.Methods("DELETE").HandlerFunc(a.DeleteBucketHandler)
|
|
|
|
|
2016-02-27 06:04:52 -05:00
|
|
|
/// Root operation
|
|
|
|
|
|
|
|
// ListBuckets
|
2016-02-16 21:50:36 -05:00
|
|
|
api.Methods("GET").HandlerFunc(a.ListBucketsHandler)
|
2015-07-01 03:37:43 -04:00
|
|
|
}
|
|
|
|
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-12 18:27:10 -05:00
|
|
|
// configureServer handler returns final handler for the http server.
|
|
|
|
func configureServerHandler(filesystem fs.Filesystem) http.Handler {
|
|
|
|
// Access credentials.
|
|
|
|
cred := serverConfig.GetCredential()
|
|
|
|
|
|
|
|
// Server addr.
|
|
|
|
addr := serverConfig.GetAddr()
|
|
|
|
|
|
|
|
// Initialize API.
|
|
|
|
api := storageAPI{
|
|
|
|
Filesystem: filesystem,
|
|
|
|
}
|
|
|
|
|
2016-01-25 01:26:53 -05:00
|
|
|
// Split host port.
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-12 18:27:10 -05:00
|
|
|
host, port, _ := net.SplitHostPort(addr)
|
2016-01-25 01:26:53 -05:00
|
|
|
|
2016-01-27 04:52:54 -05:00
|
|
|
// Default host is 'localhost', if no host present.
|
|
|
|
if host == "" {
|
|
|
|
host = "localhost"
|
|
|
|
}
|
2016-01-25 01:26:53 -05:00
|
|
|
|
|
|
|
// Initialize minio client for AWS Signature Version '4'
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-12 18:27:10 -05:00
|
|
|
disableSSL := !isSSL() // Insecure true when SSL is false.
|
|
|
|
client, e := minio.NewV4(net.JoinHostPort(host, port), cred.AccessKeyID, cred.SecretAccessKey, disableSSL)
|
2016-01-25 01:26:53 -05:00
|
|
|
fatalIf(probe.NewError(e), "Unable to initialize minio client", nil)
|
|
|
|
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-12 18:27:10 -05:00
|
|
|
// Initialize Web.
|
|
|
|
web := &webAPI{
|
|
|
|
FSPath: filesystem.GetRootPath(),
|
2016-01-27 04:52:54 -05:00
|
|
|
Client: client,
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-12 18:27:10 -05:00
|
|
|
apiAddress: addr,
|
|
|
|
accessKeyID: cred.AccessKeyID,
|
|
|
|
secretAccessKey: cred.SecretAccessKey,
|
2015-09-19 05:36:50 -04:00
|
|
|
}
|
2016-02-18 05:13:52 -05:00
|
|
|
|
2016-02-04 17:57:20 -05:00
|
|
|
var handlerFns = []HandlerFunc{
|
2016-02-16 21:50:36 -05:00
|
|
|
// Redirect some pre-defined browser request paths to a static
|
|
|
|
// location prefix.
|
|
|
|
setBrowserRedirectHandler,
|
|
|
|
// Validates if incoming request is for restricted buckets.
|
|
|
|
setPrivateBucketHandler,
|
|
|
|
// Adds cache control for all browser requests.
|
|
|
|
setBrowserCacheControlHandler,
|
|
|
|
// Validates all incoming requests to have a valid date header.
|
2016-02-04 17:57:20 -05:00
|
|
|
setTimeValidityHandler,
|
2016-02-16 21:50:36 -05:00
|
|
|
// CORS setting for all browser API requests.
|
|
|
|
setCorsHandler,
|
|
|
|
// Validates all incoming URL resources, for invalid/unsupported
|
|
|
|
// resources client receives a HTTP error.
|
2016-02-04 17:57:20 -05:00
|
|
|
setIgnoreResourcesHandler,
|
2016-02-16 21:50:36 -05:00
|
|
|
// Auth handler verifies incoming authorization headers and
|
|
|
|
// routes them accordingly. Client receives a HTTP error for
|
|
|
|
// invalid/unsupported signatures.
|
2016-02-15 20:42:39 -05:00
|
|
|
setAuthHandler,
|
2015-10-07 02:32:20 -04:00
|
|
|
}
|
2016-02-18 05:13:52 -05:00
|
|
|
|
|
|
|
// Initialize router.
|
2015-06-30 23:15:48 -04:00
|
|
|
mux := router.NewRouter()
|
2016-02-18 05:13:52 -05:00
|
|
|
|
|
|
|
// Register all API handlers.
|
|
|
|
registerAPIHandlers(mux, api, web)
|
|
|
|
|
|
|
|
// Register rest of the handlers.
|
2016-02-04 17:57:20 -05:00
|
|
|
return registerHandlers(mux, handlerFns...)
|
2015-06-30 23:15:48 -04:00
|
|
|
}
|