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 (
|
|
|
|
"net/http"
|
|
|
|
|
2015-08-22 21:34:00 -04:00
|
|
|
router "github.com/gorilla/mux"
|
2015-10-16 14:26:01 -04:00
|
|
|
"github.com/minio/minio/pkg/fs"
|
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
|
|
|
// configureServer handler returns final handler for the http server.
|
|
|
|
func configureServerHandler(filesystem fs.Filesystem) http.Handler {
|
|
|
|
// Initialize API.
|
|
|
|
api := storageAPI{
|
|
|
|
Filesystem: filesystem,
|
|
|
|
}
|
|
|
|
// Initialize Web.
|
|
|
|
web := &webAPI{
|
2016-03-31 09:57:29 -04:00
|
|
|
Filesystem: filesystem,
|
2015-09-19 05:36:50 -04:00
|
|
|
}
|
2016-02-18 05:13:52 -05:00
|
|
|
|
2016-03-27 15:37:21 -04:00
|
|
|
// Initialize router.
|
|
|
|
mux := router.NewRouter()
|
|
|
|
|
|
|
|
// Register all routers.
|
|
|
|
registerWebRouter(mux, web)
|
|
|
|
registerAPIRouter(mux, api)
|
|
|
|
// Add new routers here.
|
|
|
|
|
|
|
|
// List of some generic handlers which are applied for all
|
|
|
|
// incoming requests.
|
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,
|
2016-03-27 15:37:21 -04:00
|
|
|
// Add new handlers here.
|
2015-10-07 02:32:20 -04:00
|
|
|
}
|
2016-02-18 05:13:52 -05:00
|
|
|
|
|
|
|
// 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
|
|
|
}
|