mirror of
https://github.com/minio/minio.git
synced 2024-12-26 23:25:54 -05:00
Merge pull request #325 from harshavardhana/pr_out_restructure_minio_api_move_signature_checks_from_utils_to_api
This commit is contained in:
commit
b61daa0f87
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,10 +1,10 @@
|
|||||||
**/*.swp
|
**/*.swp
|
||||||
site/
|
|
||||||
cover.out
|
cover.out
|
||||||
*~
|
*~
|
||||||
minio
|
minio
|
||||||
|
!*/
|
||||||
|
site/
|
||||||
**/*.test
|
**/*.test
|
||||||
**/*.sublime-workspace
|
**/*.sublime-workspace
|
||||||
verifier
|
|
||||||
/.idea/
|
/.idea/
|
||||||
/Minio.iml
|
/Minio.iml
|
||||||
|
2
main.go
2
main.go
@ -68,7 +68,7 @@ func runCmd(c *cli.Context) {
|
|||||||
TLS: false,
|
TLS: false,
|
||||||
CertFile: "",
|
CertFile: "",
|
||||||
KeyFile: "",
|
KeyFile: "",
|
||||||
APIType: server.WebAPI{
|
APIType: server.Web{
|
||||||
Websocket: false,
|
Websocket: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minioapi
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minioapi
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
@ -14,14 +14,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minioapi
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/minio-io/minio/pkg/utils/config"
|
"github.com/minio-io/minio/pkg/utils/config"
|
||||||
"github.com/minio-io/minio/pkg/utils/crypto/signers"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type vHandler struct {
|
type vHandler struct {
|
||||||
@ -70,7 +69,7 @@ func (h vHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.WriteHeader(error.HTTPStatusCode)
|
w.WriteHeader(error.HTTPStatusCode)
|
||||||
w.Write(writeErrorResponse(w, errorResponse, acceptsContentType))
|
w.Write(writeErrorResponse(w, errorResponse, acceptsContentType))
|
||||||
} else {
|
} else {
|
||||||
ok, _ = signers.ValidateRequest(user, r)
|
ok, _ = ValidateRequest(user, r)
|
||||||
if ok {
|
if ok {
|
||||||
h.handler.ServeHTTP(w, r)
|
h.handler.ServeHTTP(w, r)
|
||||||
} else {
|
} else {
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minioapi
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minioapi
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minioapi
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sort"
|
"sort"
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minioapi
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package signers
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minioapi_test
|
package api_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@ -28,7 +28,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/minio-io/minio/pkg/api/minioapi"
|
"github.com/minio-io/minio/pkg/api"
|
||||||
mstorage "github.com/minio-io/minio/pkg/storage"
|
mstorage "github.com/minio-io/minio/pkg/storage"
|
||||||
"github.com/minio-io/minio/pkg/storage/memory"
|
"github.com/minio-io/minio/pkg/storage/memory"
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ var _ = Suite(&MySuite{})
|
|||||||
|
|
||||||
func (s *MySuite) TestNonExistantObject(c *C) {
|
func (s *MySuite) TestNonExistantObject(c *C) {
|
||||||
_, _, storage := memory.Start()
|
_, _, storage := memory.Start()
|
||||||
httpHandler := minioapi.HTTPHandler("", storage)
|
httpHandler := api.HTTPHandler("", storage)
|
||||||
testServer := httptest.NewServer(httpHandler)
|
testServer := httptest.NewServer(httpHandler)
|
||||||
defer testServer.Close()
|
defer testServer.Close()
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ func (s *MySuite) TestNonExistantObject(c *C) {
|
|||||||
|
|
||||||
func (s *MySuite) TestEmptyObject(c *C) {
|
func (s *MySuite) TestEmptyObject(c *C) {
|
||||||
_, _, storage := memory.Start()
|
_, _, storage := memory.Start()
|
||||||
httpHandler := minioapi.HTTPHandler("", storage)
|
httpHandler := api.HTTPHandler("", storage)
|
||||||
testServer := httptest.NewServer(httpHandler)
|
testServer := httptest.NewServer(httpHandler)
|
||||||
defer testServer.Close()
|
defer testServer.Close()
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ func (s *MySuite) TestEmptyObject(c *C) {
|
|||||||
|
|
||||||
func (s *MySuite) TestObject(c *C) {
|
func (s *MySuite) TestObject(c *C) {
|
||||||
_, _, storage := memory.Start()
|
_, _, storage := memory.Start()
|
||||||
httpHandler := minioapi.HTTPHandler("", storage)
|
httpHandler := api.HTTPHandler("", storage)
|
||||||
testServer := httptest.NewServer(httpHandler)
|
testServer := httptest.NewServer(httpHandler)
|
||||||
defer testServer.Close()
|
defer testServer.Close()
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ func (s *MySuite) TestObject(c *C) {
|
|||||||
|
|
||||||
func (s *MySuite) TestMultipleObjects(c *C) {
|
func (s *MySuite) TestMultipleObjects(c *C) {
|
||||||
_, _, storage := memory.Start()
|
_, _, storage := memory.Start()
|
||||||
httpHandler := minioapi.HTTPHandler("", storage)
|
httpHandler := api.HTTPHandler("", storage)
|
||||||
testServer := httptest.NewServer(httpHandler)
|
testServer := httptest.NewServer(httpHandler)
|
||||||
defer testServer.Close()
|
defer testServer.Close()
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ func (s *MySuite) TestMultipleObjects(c *C) {
|
|||||||
|
|
||||||
func (s *MySuite) TestNotImplemented(c *C) {
|
func (s *MySuite) TestNotImplemented(c *C) {
|
||||||
_, _, storage := memory.Start()
|
_, _, storage := memory.Start()
|
||||||
httpHandler := minioapi.HTTPHandler("", storage)
|
httpHandler := api.HTTPHandler("", storage)
|
||||||
testServer := httptest.NewServer(httpHandler)
|
testServer := httptest.NewServer(httpHandler)
|
||||||
defer testServer.Close()
|
defer testServer.Close()
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ func (s *MySuite) TestNotImplemented(c *C) {
|
|||||||
|
|
||||||
func (s *MySuite) TestHeader(c *C) {
|
func (s *MySuite) TestHeader(c *C) {
|
||||||
_, _, storage := memory.Start()
|
_, _, storage := memory.Start()
|
||||||
httpHandler := minioapi.HTTPHandler("", storage)
|
httpHandler := api.HTTPHandler("", storage)
|
||||||
testServer := httptest.NewServer(httpHandler)
|
testServer := httptest.NewServer(httpHandler)
|
||||||
defer testServer.Close()
|
defer testServer.Close()
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ func (s *MySuite) TestHeader(c *C) {
|
|||||||
|
|
||||||
func (s *MySuite) TestPutBucket(c *C) {
|
func (s *MySuite) TestPutBucket(c *C) {
|
||||||
_, _, storage := memory.Start()
|
_, _, storage := memory.Start()
|
||||||
httpHandler := minioapi.HTTPHandler("", storage)
|
httpHandler := api.HTTPHandler("", storage)
|
||||||
testServer := httptest.NewServer(httpHandler)
|
testServer := httptest.NewServer(httpHandler)
|
||||||
defer testServer.Close()
|
defer testServer.Close()
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ func (s *MySuite) TestPutBucket(c *C) {
|
|||||||
|
|
||||||
func (s *MySuite) TestPutObject(c *C) {
|
func (s *MySuite) TestPutObject(c *C) {
|
||||||
_, _, storage := memory.Start()
|
_, _, storage := memory.Start()
|
||||||
httpHandler := minioapi.HTTPHandler("", storage)
|
httpHandler := api.HTTPHandler("", storage)
|
||||||
testServer := httptest.NewServer(httpHandler)
|
testServer := httptest.NewServer(httpHandler)
|
||||||
defer testServer.Close()
|
defer testServer.Close()
|
||||||
|
|
||||||
@ -299,7 +299,7 @@ func (s *MySuite) TestPutObject(c *C) {
|
|||||||
|
|
||||||
func (s *MySuite) TestListBuckets(c *C) {
|
func (s *MySuite) TestListBuckets(c *C) {
|
||||||
_, _, storage := memory.Start()
|
_, _, storage := memory.Start()
|
||||||
httpHandler := minioapi.HTTPHandler("", storage)
|
httpHandler := api.HTTPHandler("", storage)
|
||||||
testServer := httptest.NewServer(httpHandler)
|
testServer := httptest.NewServer(httpHandler)
|
||||||
defer testServer.Close()
|
defer testServer.Close()
|
||||||
|
|
||||||
@ -339,8 +339,8 @@ func (s *MySuite) TestListBuckets(c *C) {
|
|||||||
c.Assert(listResponse.Buckets.Bucket[1].Name, Equals, "foo")
|
c.Assert(listResponse.Buckets.Bucket[1].Name, Equals, "foo")
|
||||||
}
|
}
|
||||||
|
|
||||||
func readListBucket(reader io.Reader) (minioapi.BucketListResponse, error) {
|
func readListBucket(reader io.Reader) (api.BucketListResponse, error) {
|
||||||
var results minioapi.BucketListResponse
|
var results api.BucketListResponse
|
||||||
decoder := xml.NewDecoder(reader)
|
decoder := xml.NewDecoder(reader)
|
||||||
err := decoder.Decode(&results)
|
err := decoder.Decode(&results)
|
||||||
return results, err
|
return results, err
|
||||||
@ -378,7 +378,7 @@ func verifyHeaders(c *C, header http.Header, date time.Time, size int, contentTy
|
|||||||
|
|
||||||
func (s *MySuite) TestXMLNameNotInBucketListJson(c *C) {
|
func (s *MySuite) TestXMLNameNotInBucketListJson(c *C) {
|
||||||
_, _, storage := memory.Start()
|
_, _, storage := memory.Start()
|
||||||
httpHandler := minioapi.HTTPHandler("", storage)
|
httpHandler := api.HTTPHandler("", storage)
|
||||||
testServer := httptest.NewServer(httpHandler)
|
testServer := httptest.NewServer(httpHandler)
|
||||||
defer testServer.Close()
|
defer testServer.Close()
|
||||||
|
|
||||||
@ -403,7 +403,7 @@ func (s *MySuite) TestXMLNameNotInBucketListJson(c *C) {
|
|||||||
|
|
||||||
func (s *MySuite) TestXMLNameNotInObjectListJson(c *C) {
|
func (s *MySuite) TestXMLNameNotInObjectListJson(c *C) {
|
||||||
_, _, storage := memory.Start()
|
_, _, storage := memory.Start()
|
||||||
httpHandler := minioapi.HTTPHandler("", storage)
|
httpHandler := api.HTTPHandler("", storage)
|
||||||
testServer := httptest.NewServer(httpHandler)
|
testServer := httptest.NewServer(httpHandler)
|
||||||
defer testServer.Close()
|
defer testServer.Close()
|
||||||
|
|
||||||
@ -428,7 +428,7 @@ func (s *MySuite) TestXMLNameNotInObjectListJson(c *C) {
|
|||||||
|
|
||||||
func (s *MySuite) TestContentTypePersists(c *C) {
|
func (s *MySuite) TestContentTypePersists(c *C) {
|
||||||
_, _, storage := memory.Start()
|
_, _, storage := memory.Start()
|
||||||
httpHandler := minioapi.HTTPHandler("", storage)
|
httpHandler := api.HTTPHandler("", storage)
|
||||||
testServer := httptest.NewServer(httpHandler)
|
testServer := httptest.NewServer(httpHandler)
|
||||||
defer testServer.Close()
|
defer testServer.Close()
|
||||||
|
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minioapi
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minioapi
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minioapi
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minioapi
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minioapi
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package webuiapi
|
package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
@ -22,8 +22,8 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/minio-io/minio/pkg/api/minioapi"
|
"github.com/minio-io/minio/pkg/api"
|
||||||
"github.com/minio-io/minio/pkg/api/webuiapi"
|
"github.com/minio-io/minio/pkg/api/web"
|
||||||
"github.com/minio-io/minio/pkg/server/httpserver"
|
"github.com/minio-io/minio/pkg/server/httpserver"
|
||||||
mstorage "github.com/minio-io/minio/pkg/storage"
|
mstorage "github.com/minio-io/minio/pkg/storage"
|
||||||
"github.com/minio-io/minio/pkg/storage/file"
|
"github.com/minio-io/minio/pkg/storage/file"
|
||||||
@ -45,8 +45,8 @@ type MinioAPI struct {
|
|||||||
StorageType StorageType
|
StorageType StorageType
|
||||||
}
|
}
|
||||||
|
|
||||||
// WebAPI - webui related
|
// Web - web related
|
||||||
type WebAPI struct {
|
type Web struct {
|
||||||
Websocket bool // TODO
|
Websocket bool // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,13 +85,13 @@ func getHTTPChannels(configs []Config) (ctrlChans []chan<- string, statusChans [
|
|||||||
|
|
||||||
ctrlChans, statusChans, storage = getStorageChannels(k.StorageType)
|
ctrlChans, statusChans, storage = getStorageChannels(k.StorageType)
|
||||||
// start minio api in a web server, pass storage driver into it
|
// start minio api in a web server, pass storage driver into it
|
||||||
ctrlChan, statusChan, _ = httpserver.Start(minioapi.HTTPHandler(config.Domain, storage), httpConfig)
|
ctrlChan, statusChan, _ = httpserver.Start(api.HTTPHandler(config.Domain, storage), httpConfig)
|
||||||
|
|
||||||
ctrlChans = append(ctrlChans, ctrlChan)
|
ctrlChans = append(ctrlChans, ctrlChan)
|
||||||
statusChans = append(statusChans, statusChan)
|
statusChans = append(statusChans, statusChan)
|
||||||
|
|
||||||
}
|
}
|
||||||
case WebAPI:
|
case Web:
|
||||||
{
|
{
|
||||||
var httpConfig = httpserver.Config{}
|
var httpConfig = httpserver.Config{}
|
||||||
httpConfig.Address = config.Address
|
httpConfig.Address = config.Address
|
||||||
@ -100,7 +100,7 @@ func getHTTPChannels(configs []Config) (ctrlChans []chan<- string, statusChans [
|
|||||||
httpConfig.KeyFile = config.KeyFile
|
httpConfig.KeyFile = config.KeyFile
|
||||||
|
|
||||||
httpConfig.Websocket = k.Websocket
|
httpConfig.Websocket = k.Websocket
|
||||||
ctrlChan, statusChan, _ = httpserver.Start(webuiapi.HTTPHandler(), httpConfig)
|
ctrlChan, statusChan, _ = httpserver.Start(web.HTTPHandler(), httpConfig)
|
||||||
|
|
||||||
ctrlChans = append(ctrlChans, ctrlChan)
|
ctrlChans = append(ctrlChans, ctrlChan)
|
||||||
statusChans = append(statusChans, statusChan)
|
statusChans = append(statusChans, statusChan)
|
||||||
|
Loading…
Reference in New Issue
Block a user