Compare commits

..

No commits in common. "master" and "v0.0.4" have entirely different histories.

4 changed files with 8 additions and 22 deletions

View file

@ -117,7 +117,6 @@ func main() {
"server_mode", serverMode,
// Generic OBS
"obs_bucket", defaultObsOpts.BucketName,
"obs_remove_bucket_name", defaultObsOpts.RemoveBucketName,
"obs_redirect_secure", defaultObsOpts.RedirectSecure,
"obs_host_redirect", defaultObsOpts.HostRedirect,
"obs_redirect_code", defaultObsOpts.RedirectCode,

13
obs.go
View file

@ -16,14 +16,11 @@ type obsOptions struct {
RedirectCode int // HTTP redirect status code
URLExpiry time.Duration
HostRedirect string
RemoveBucketName bool
}
var defaultObsOpts = obsOptions{
URLExpiry: maxURLExpiry,
RedirectCode: http.StatusMovedPermanently, // 301
RemoveBucketName: false,
URLExpiry: maxURLExpiry,
RedirectCode: http.StatusMovedPermanently, // 301
}
func (opts *obsOptions) Bind(fs *flag.FlagSet) (err error) {
@ -67,11 +64,5 @@ func (opts *obsOptions) Bind(fs *flag.FlagSet) (err error) {
vObsUrlExpiry = obsUrlExpiry
}
fs.DurationVar(&opts.URLExpiry, "obs-url-expiry", vObsUrlExpiry, "OBS Redirection URL expiry")
var vObsRemoveBucketName = opts.RemoveBucketName
if sObsRemoveBucketName := os.Getenv("OBS_REMOVE_BUCKET_NAME"); sObsRemoveBucketName != "" {
vObsRemoveBucketName, _ = strconv.ParseBool(sObsRemoveBucketName)
}
fs.BoolVar(&opts.RemoveBucketName, "obs-remove-bucket-name", vObsRemoveBucketName, "OBS Remove Bucket name from prefix")
return
}

View file

@ -73,11 +73,9 @@ func (s *serverS3) handle(ctx *fasthttp.RequestCtx) {
path := ctx.Path()
_path := bytes.TrimLeft(path, "/")
if s.opts.RemoveBucketName {
if _, _pathWithoutBucketName, found := bytes.Cut(_path, []byte(`/`)); found {
// no need to check `isVirtualHostStyle` since this is our own implementation of handling request URI
_path = _pathWithoutBucketName
}
if _, _pathWithoutBucketName, found := bytes.Cut(_path, []byte(`/`)); found {
// no need to check `isVirtualHostStyle` since this is our own implementation of handling request URI
_path = _pathWithoutBucketName
}
objectName := unsafeByteSliceToString(_path)

View file

@ -62,11 +62,9 @@ func (s *serverStorj) handle(ctx *fasthttp.RequestCtx) {
bucketName := s.opts.BucketName
path := ctx.Path()
_path := bytes.TrimLeft(path, "/")
if s.opts.RemoveBucketName {
if _, _pathWithoutBucketName, found := bytes.Cut(_path, []byte(`/`)); found {
// no need to check `isVirtualHostStyle` since this is our own implementation of handling request URI
_path = _pathWithoutBucketName
}
if _, _pathWithoutBucketName, found := bytes.Cut(_path, []byte(`/`)); found {
// no need to check `isVirtualHostStyle` since this is our own implementation of handling request URI
_path = _pathWithoutBucketName
}
objectName := unsafeByteSliceToString(_path)