diff --git a/logger.go b/logger.go index 905b578..ad9bfc1 100644 --- a/logger.go +++ b/logger.go @@ -7,17 +7,16 @@ import ( ) // Logger logs HTTP requests -func Logger(inner http.Handler, name string) http.Handler { +func Logger(inner http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { start := time.Now() inner.ServeHTTP(w, r) log.Printf( - "%s\t%s\t%s\t%s", + "%s\t%s\t%s", r.Method, r.RequestURI, - name, time.Since(start), ) }) diff --git a/router.go b/router.go index 327aeb3..bad83b2 100644 --- a/router.go +++ b/router.go @@ -14,12 +14,11 @@ func NewRouter() *mux.Router { var handler http.Handler handler = route.HandlerFunc - handler = Logger(handler, route.Name) + handler = Logger(handler) router. Methods(route.Method). Path(route.Pattern). - Name(route.Name). Handler(handler) } diff --git a/routes.go b/routes.go index b446530..d1eef51 100644 --- a/routes.go +++ b/routes.go @@ -4,7 +4,6 @@ import "net/http" // Route represents a path of the API type Route struct { - Name string Method string Pattern string HandlerFunc http.HandlerFunc @@ -15,49 +14,41 @@ type Routes []Route var routes = Routes{ Route{ - "Redirect to /buckets", "GET", "/", indexPageHandler, }, Route{ - "Load Buckets Page", "GET", "/buckets", bucketsPageHandler, }, Route{ - "Load Bucket Page", "GET", "/buckets/{bucketName}", bucketPageHandler, }, Route{ - "Create Bucket", "POST", "/api/buckets", createBucketHandler, }, Route{ - "Delete Bucket", "DELETE", "/api/buckets/{bucketName}", deleteBucketHandler, }, Route{ - "Download Object", "GET", "/api/buckets/{bucketName}/objects/{objectName}", getObjectHandler, }, Route{ - "Upload Object", "POST", "/api/buckets/{bucketName}/objects", createObjectHandler, }, Route{ - "Delete Object", "DELETE", "/api/buckets/{bucketName}/objects/{objectName}", deleteObjectHandler,