|
@ -1,6 +1,7 @@ |
|
|
package s3api |
|
|
package s3api |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
|
|
|
"fmt" |
|
|
"net/http" |
|
|
"net/http" |
|
|
|
|
|
|
|
|
"github.com/gorilla/mux" |
|
|
"github.com/gorilla/mux" |
|
@ -9,6 +10,7 @@ import ( |
|
|
|
|
|
|
|
|
type S3ApiServerOption struct { |
|
|
type S3ApiServerOption struct { |
|
|
Filer string |
|
|
Filer string |
|
|
|
|
|
Port int |
|
|
FilerGrpcAddress string |
|
|
FilerGrpcAddress string |
|
|
Config string |
|
|
Config string |
|
|
DomainName string |
|
|
DomainName string |
|
@ -37,7 +39,10 @@ func (s3a *S3ApiServer) registerRouter(router *mux.Router) { |
|
|
apiRouter := router.PathPrefix("/").Subrouter() |
|
|
apiRouter := router.PathPrefix("/").Subrouter() |
|
|
var routers []*mux.Router |
|
|
var routers []*mux.Router |
|
|
if s3a.option.DomainName != "" { |
|
|
if s3a.option.DomainName != "" { |
|
|
routers = append(routers, apiRouter.Host("{bucket:.+}."+s3a.option.DomainName).Subrouter()) |
|
|
|
|
|
|
|
|
routers = append(routers, apiRouter.Host( |
|
|
|
|
|
fmt.Sprintf("%s.%s:%d", "{bucket:.+}", s3a.option.DomainName, s3a.option.Port)).Subrouter()) |
|
|
|
|
|
routers = append(routers, apiRouter.Host( |
|
|
|
|
|
fmt.Sprintf("%s.%s", "{bucket:.+}", s3a.option.DomainName)).Subrouter()) |
|
|
} |
|
|
} |
|
|
routers = append(routers, apiRouter.PathPrefix("/{bucket}").Subrouter()) |
|
|
routers = append(routers, apiRouter.PathPrefix("/{bucket}").Subrouter()) |
|
|
|
|
|
|
|
|