Merge pull request #557 from harshavardhana/pr_out_make_builddate_universal

This commit is contained in:
Harshavardhana 2015-04-30 21:19:04 -07:00
commit c01fb92eca
6 changed files with 20 additions and 37 deletions

View File

@ -49,7 +49,7 @@ minio: pre-build build-all test-all
install: minio install: minio
@echo "Installing minio:" @echo "Installing minio:"
@godep go install -a -ldflags "-X main.BuildDate `date '+%FT%T.%N%:z'`" github.com/minio-io/minio @godep go install -a -ldflags "-X main.BuildDate `date --universal '+%FT%T.%N%:z'`" github.com/minio-io/minio
save: restore save: restore
@godep save ./... @godep save ./...

14
main.go
View File

@ -93,11 +93,11 @@ EXAMPLES:
} }
var flags = []cli.Flag{ var flags = []cli.Flag{
cli.StringFlag{ // cli.StringFlag{
Name: "domain", // Name: "domain",
Value: "", // Value: "",
Usage: "domain used for routing incoming API requests", // Usage: "domain used for routing incoming API requests",
}, // },
cli.StringFlag{ cli.StringFlag{
Name: "api-address", Name: "api-address",
Value: ":9000", Value: ":9000",
@ -191,7 +191,7 @@ func getAPIServerConfig(c *cli.Context) httpserver.Config {
} }
tls := (certFile != "" && keyFile != "") tls := (certFile != "" && keyFile != "")
return httpserver.Config{ return httpserver.Config{
Domain: c.GlobalString("domain"), // Domain: c.GlobalString("domain"),
Address: c.GlobalString("api-address"), Address: c.GlobalString("api-address"),
TLS: tls, TLS: tls,
CertFile: certFile, CertFile: certFile,
@ -201,7 +201,7 @@ func getAPIServerConfig(c *cli.Context) httpserver.Config {
func getWebServerConfigFunc(c *cli.Context) server.StartServerFunc { func getWebServerConfigFunc(c *cli.Context) server.StartServerFunc {
config := httpserver.Config{ config := httpserver.Config{
Domain: c.GlobalString("domain"), // Domain: c.GlobalString("domain"),
Address: c.GlobalString("web-address"), Address: c.GlobalString("web-address"),
TLS: false, TLS: false,
CertFile: "", CertFile: "",

View File

@ -47,6 +47,7 @@ func pathMux(api minioAPI, mux *router.Router) *router.Router {
return mux return mux
} }
/*
// Domain based routing // Domain based routing
func domainMux(api minioAPI, mux *router.Router) *router.Router { func domainMux(api minioAPI, mux *router.Router) *router.Router {
mux.HandleFunc("/", mux.HandleFunc("/",
@ -63,15 +64,16 @@ func domainMux(api minioAPI, mux *router.Router) *router.Router {
return mux return mux
} }
*/
// Get proper router based on domain availability // Get proper router based on domain availability
func getMux(api minioAPI, mux *router.Router) *router.Router { func getMux(api minioAPI, mux *router.Router) *router.Router {
switch true { switch true {
case api.domain == "": case api.domain == "":
return pathMux(api, mux) return pathMux(api, mux)
case api.domain != "": // case api.domain != "":
s := mux.Host(api.domain).Subrouter() // s := mux.Host(api.domain).Subrouter()
return domainMux(api, s) // return domainMux(api, s)
} }
return nil return nil
} }

View File

@ -24,13 +24,13 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"net"
"net/http" "net/http"
"net/url" "net/url"
"sort" "sort"
"strings" "strings"
"time" "time"
"github.com/gorilla/mux"
"github.com/minio-io/minio/pkg/api/config" "github.com/minio-io/minio/pkg/api/config"
) )
@ -175,8 +175,8 @@ var subResList = []string{
// <HTTP-Request-URI, from the protocol name up to the query string> + // <HTTP-Request-URI, from the protocol name up to the query string> +
// [ sub-resource, if present. For example "?acl", "?location", "?logging", or "?torrent"]; // [ sub-resource, if present. For example "?acl", "?location", "?logging", or "?torrent"];
func writeCanonicalizedResource(buf *bytes.Buffer, req *http.Request) { func writeCanonicalizedResource(buf *bytes.Buffer, req *http.Request) {
// Grab bucket name from hostname vars := mux.Vars(req)
bucket := bucketFromHostname(req) bucket := vars["bucket"]
if bucket != "" { if bucket != "" {
buf.WriteByte('/') buf.WriteByte('/')
buf.WriteString(bucket) buf.WriteString(bucket)
@ -203,23 +203,3 @@ func writeCanonicalizedResource(buf *bytes.Buffer, req *http.Request) {
} }
} }
} }
// Convert subdomain http request into bucketname if possible
func bucketFromHostname(req *http.Request) string {
host, _, _ := net.SplitHostPort(req.Host)
// Verify incoming request if only IP with no bucket subdomain
if net.ParseIP(host) != nil {
return ""
}
if host == "" {
host = req.URL.Host
}
// Grab the bucket from the incoming hostname
host = strings.TrimSpace(host)
hostParts := strings.Split(host, ".")
if len(hostParts) > 2 {
return hostParts[0]
}
return ""
}

View File

@ -29,7 +29,7 @@ type Config struct {
CertFile string CertFile string
KeyFile string KeyFile string
Websocket bool // TODO Websocket bool // TODO
Domain string // Domain string
} }
// Server - http server related // Server - http server related

View File

@ -41,7 +41,8 @@ type MemoryFactory struct {
func (f MemoryFactory) GetStartServerFunc() StartServerFunc { func (f MemoryFactory) GetStartServerFunc() StartServerFunc {
return func() (chan<- string, <-chan error) { return func() (chan<- string, <-chan error) {
_, _, driver := memory.Start(f.MaxMemory, 1*time.Hour) _, _, driver := memory.Start(f.MaxMemory, 1*time.Hour)
ctrl, status, _ := httpserver.Start(api.HTTPHandler(f.Domain, driver), f.Config) //ctrl, status, _ := httpserver.Start(api.HTTPHandler(f.Domain, driver), f.Config)
ctrl, status, _ := httpserver.Start(api.HTTPHandler("", driver), f.Config)
return ctrl, status return ctrl, status
} }
} }
@ -69,7 +70,7 @@ type DonutFactory struct {
func (f DonutFactory) GetStartServerFunc() StartServerFunc { func (f DonutFactory) GetStartServerFunc() StartServerFunc {
return func() (chan<- string, <-chan error) { return func() (chan<- string, <-chan error) {
_, _, driver := donut.Start(f.Paths) _, _, driver := donut.Start(f.Paths)
ctrl, status, _ := httpserver.Start(api.HTTPHandler(f.Domain, driver), f.Config) ctrl, status, _ := httpserver.Start(api.HTTPHandler("", driver), f.Config)
return ctrl, status return ctrl, status
} }
} }