From c027ca9d9e2e3d410570fb0d00a9e9354d13419b Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 3 Feb 2011 15:56:02 -0800 Subject: [PATCH] Libraryify: create lib/go/blobserver/handles; move Remove --- build.pl | 10 +++++++++- lib/go/blobserver/handlers/Makefile | 11 +++++++++++ .../go/blobserver/handlers}/remove.go | 4 ++-- server/go/blobserver/Makefile | 4 ++-- server/go/blobserver/camlistored.go | 3 ++- 5 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 lib/go/blobserver/handlers/Makefile rename {server/go/blobserver => lib/go/blobserver/handlers}/remove.go (96%) diff --git a/build.pl b/build.pl index 84e23390a..def23fdc4 100755 --- a/build.pl +++ b/build.pl @@ -73,7 +73,11 @@ unless (@matches) { die "No build targets patching pattern /$target/\n"; } if (@matches > 1) { - die "Build pattern is ambiguous, matches multiple targets:\n * " . join("\n * ", @matches) . "\n"; + if (scalar(grep { $_ eq $target } @matches) == 1) { + @matches = ($target); + } else { + die "Build pattern is ambiguous, matches multiple targets:\n * " . join("\n * ", @matches) . "\n"; + } } build($matches[0]); @@ -163,6 +167,7 @@ __DATA__ - server/go/httputil - lib/go/blobref - lib/go/blobserver + - lib/go/blobserver/handlers - server/go/auth - server/go/webserver ./server/go/sigserver/Makefile @@ -210,3 +215,6 @@ __DATA__ # (no deps) ./lib/go/blobserver/Makefile - lib/go/blobref +./lib/go/blobserver/handlers/Makefile + - server/go/httputil + - lib/go/blobserver diff --git a/lib/go/blobserver/handlers/Makefile b/lib/go/blobserver/handlers/Makefile new file mode 100644 index 000000000..8bf0c2667 --- /dev/null +++ b/lib/go/blobserver/handlers/Makefile @@ -0,0 +1,11 @@ +include $(GOROOT)/src/Make.inc + +PREREQ=$(QUOTED_GOROOT)/pkg/$(GOOS)_$(GOARCH)/camli/blobserver.a\ + $(QUOTED_GOROOT)/pkg/$(GOOS)_$(GOARCH)/camli/blobref.a\ + $(QUOTED_GOROOT)/pkg/$(GOOS)_$(GOARCH)/camli/httputil.a\ + +TARG=camli/blobserver/handlers +GOFILES=\ + remove.go\ + +include $(GOROOT)/src/Make.pkg diff --git a/server/go/blobserver/remove.go b/lib/go/blobserver/handlers/remove.go similarity index 96% rename from server/go/blobserver/remove.go rename to lib/go/blobserver/handlers/remove.go index af55c937f..c55dc53ac 100644 --- a/server/go/blobserver/remove.go +++ b/lib/go/blobserver/handlers/remove.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package main +package handlers import ( "camli/blobref" @@ -27,7 +27,7 @@ import ( const maxRemovesPerRequest = 1000 -func createRemoveHandler(storage blobserver.Storage, partition string) func(http.ResponseWriter, *http.Request) { +func CreateRemoveHandler(storage blobserver.Storage, partition string) func(http.ResponseWriter, *http.Request) { return func(conn http.ResponseWriter, req *http.Request) { handleRemove(conn, req, storage, partition) } diff --git a/server/go/blobserver/Makefile b/server/go/blobserver/Makefile index 320caf25f..1a409cbf4 100644 --- a/server/go/blobserver/Makefile +++ b/server/go/blobserver/Makefile @@ -1,6 +1,7 @@ include $(GOROOT)/src/Make.inc -PREREQ=$(QUOTED_GOROOT)/pkg/$(GOOS)_$(GOARCH)/camli/blobserver.a +PREREQ=$(QUOTED_GOROOT)/pkg/$(GOOS)_$(GOARCH)/camli/blobserver.a\ + $(QUOTED_GOROOT)/pkg/$(GOOS)_$(GOARCH)/camli/blobserver/handlers.a\ TARG=camlistored GOFILES=\ @@ -11,7 +12,6 @@ GOFILES=\ partitions.go\ preupload.go\ range.go\ - remove.go\ temp_testing.go\ upload.go\ util.go\ diff --git a/server/go/blobserver/camlistored.go b/server/go/blobserver/camlistored.go index 9d6fa6f27..edd9b9b32 100644 --- a/server/go/blobserver/camlistored.go +++ b/server/go/blobserver/camlistored.go @@ -9,6 +9,7 @@ import ( "camli/httputil" "camli/webserver" "camli/blobserver" + "camli/blobserver/handlers" "flag" "fmt" "http" @@ -90,7 +91,7 @@ func handleCamli(conn http.ResponseWriter, req *http.Request) { handler = auth.RequireAuth(handleMultiPartUpload) case "remove": // Currently only allows removing from a non-main partition. - handler = auth.RequireAuth(createRemoveHandler(storage, partition)) + handler = auth.RequireAuth(handlers.CreateRemoveHandler(storage, partition)) // Not part of the spec: case "testform": // debug only