forked from google/go-cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
blob: create URLMux type for scheme registration
Added URLOpener types to all of the provider packages. Fixes google#931
- Loading branch information
Showing
17 changed files
with
617 additions
and
374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2019 The Go Cloud Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// Package anyblob provides an Open function that opens buckets backed | ||
// by GCS, S3, Azure Storage, filesystem, and memory. | ||
package anyblob | ||
|
||
import ( | ||
"context" | ||
|
||
"gocloud.dev/blob" | ||
"gocloud.dev/blob/azureblob" | ||
"gocloud.dev/blob/fileblob" | ||
"gocloud.dev/blob/gcsblob" | ||
"gocloud.dev/blob/memblob" | ||
"gocloud.dev/blob/s3blob" | ||
) | ||
|
||
// Open opens a bucket URL, allowing URL overrides for all openers that | ||
// support it. See the URLOpener types in various provider packages for | ||
// more details. | ||
func Open(ctx context.Context, urlstr string) (*blob.Bucket, error) { | ||
return mux.Open(ctx, urlstr) | ||
} | ||
|
||
var mux = blob.NewURLMux(map[string]blob.BucketURLOpener{ | ||
azureblob.Scheme: &azureblob.URLOpener{AllowURLOverrides: true}, | ||
fileblob.Scheme: &fileblob.URLOpener{}, | ||
gcsblob.Scheme: &gcsblob.URLOpener{AllowURLOverrides: true}, | ||
memblob.Scheme: &memblob.URLOpener{}, | ||
s3blob.Scheme: &s3blob.URLOpener{AllowURLOverrides: true}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.