Merge pull request #325 from harshavardhana/pr_out_restructure_minio_api_move_signature_checks_from_utils_to_api

This commit is contained in:
Harshavardhana 2015-03-18 18:17:31 -07:00
commit b61daa0f87
18 changed files with 41 additions and 42 deletions

4
.gitignore vendored
View File

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

View File

@ -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,
}, },
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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