Restructure minio api, move signature checks from utils to Api.

This commit is contained in:
Harshavardhana 2015-03-18 17:49:33 -07:00
parent 7ddf6a9f8f
commit 7ce3ab3193
18 changed files with 41 additions and 42 deletions

4
.gitignore vendored
View File

@ -1,10 +1,10 @@
**/*.swp
site/
cover.out
*~
minio
!*/
site/
**/*.test
**/*.sublime-workspace
verifier
/.idea/
/Minio.iml

View File

@ -68,7 +68,7 @@ func runCmd(c *cli.Context) {
TLS: false,
CertFile: "",
KeyFile: "",
APIType: server.WebAPI{
APIType: server.Web{
Websocket: false,
},
}

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package minioapi
package api
import (
"log"

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package minioapi
package api
import (
"encoding/xml"

View File

@ -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 {

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package minioapi
package api
import (
"log"

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package minioapi
package api
import (
"encoding/json"

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package minioapi
package api
import (
"sort"

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package minioapi
package api
import (
"log"

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package signers
package api
import (
"bytes"

View File

@ -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()

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package minioapi
package api
import (
"net/http"

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package minioapi
package api
import (
"encoding/xml"

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package minioapi
package api
import (
"bytes"

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package minioapi
package api
import (
"errors"

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package minioapi
package api
import (
"net/url"

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package webuiapi
package web
import (
"bytes"

View File

@ -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)