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