mirror of
https://github.com/minio/minio.git
synced 2025-11-09 21:49:46 -05:00
Merge pull request #557 from harshavardhana/pr_out_make_builddate_universal
This commit is contained in:
@@ -47,6 +47,7 @@ func pathMux(api minioAPI, mux *router.Router) *router.Router {
|
||||
return mux
|
||||
}
|
||||
|
||||
/*
|
||||
// Domain based routing
|
||||
func domainMux(api minioAPI, mux *router.Router) *router.Router {
|
||||
mux.HandleFunc("/",
|
||||
@@ -63,15 +64,16 @@ func domainMux(api minioAPI, mux *router.Router) *router.Router {
|
||||
|
||||
return mux
|
||||
}
|
||||
*/
|
||||
|
||||
// Get proper router based on domain availability
|
||||
func getMux(api minioAPI, mux *router.Router) *router.Router {
|
||||
switch true {
|
||||
case api.domain == "":
|
||||
return pathMux(api, mux)
|
||||
case api.domain != "":
|
||||
s := mux.Host(api.domain).Subrouter()
|
||||
return domainMux(api, s)
|
||||
// case api.domain != "":
|
||||
// s := mux.Host(api.domain).Subrouter()
|
||||
// return domainMux(api, s)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -24,13 +24,13 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"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> +
|
||||
// [ sub-resource, if present. For example "?acl", "?location", "?logging", or "?torrent"];
|
||||
func writeCanonicalizedResource(buf *bytes.Buffer, req *http.Request) {
|
||||
// Grab bucket name from hostname
|
||||
bucket := bucketFromHostname(req)
|
||||
vars := mux.Vars(req)
|
||||
bucket := vars["bucket"]
|
||||
if bucket != "" {
|
||||
buf.WriteByte('/')
|
||||
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 ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user