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

master
Harshavardhana 10 years ago
parent 7ddf6a9f8f
commit 7ce3ab3193
  1. 4
      .gitignore
  2. 2
      main.go
  3. 2
      pkg/api/api_bucket_handlers.go
  4. 2
      pkg/api/api_definitions.go
  5. 5
      pkg/api/api_generic_handlers.go
  6. 2
      pkg/api/api_object.go
  7. 2
      pkg/api/api_policy.go
  8. 2
      pkg/api/api_response.go
  9. 2
      pkg/api/api_router.go
  10. 2
      pkg/api/api_signature.go
  11. 32
      pkg/api/api_test.go
  12. 2
      pkg/api/contenttype.go
  13. 2
      pkg/api/errors.go
  14. 2
      pkg/api/headers.go
  15. 2
      pkg/api/range.go
  16. 2
      pkg/api/resources.go
  17. 2
      pkg/api/web/web.go
  18. 14
      pkg/server/server.go

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

@ -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…
Cancel
Save