From 5aa7928111b474f7e32ecdbbd05b17cc08c2f2c6 Mon Sep 17 00:00:00 2001 From: Marius Date: Sat, 12 Mar 2016 22:01:12 +0100 Subject: [PATCH] Embed UnroutedHandler into Handler --- handler.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/handler.go b/handler.go index e5c82b5..d8460b6 100644 --- a/handler.go +++ b/handler.go @@ -8,9 +8,8 @@ import ( // Handler is a ready to use handler with routing (using pat) type Handler struct { - unroutedHandler *UnroutedHandler - routeHandler http.Handler - CompleteUploads chan FileInfo + *UnroutedHandler + http.Handler } // NewHandler creates a routed tus protocol handler. This is the simplest @@ -31,13 +30,12 @@ func NewHandler(config Config) (*Handler, error) { } routedHandler := &Handler{ - unroutedHandler: handler, - CompleteUploads: handler.CompleteUploads, + UnroutedHandler: handler, } mux := pat.New() - routedHandler.routeHandler = handler.Middleware(mux) + routedHandler.Handler = handler.Middleware(mux) mux.Post("", http.HandlerFunc(handler.PostFile)) mux.Head(":id", http.HandlerFunc(handler.HeadFile)) @@ -55,8 +53,3 @@ func NewHandler(config Config) (*Handler, error) { return routedHandler, nil } - -// ServeHTTP Implements the http.Handler interface. -func (rHandler *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - rHandler.routeHandler.ServeHTTP(w, r) -}