Remove route name

This commit is contained in:
Lena Fuhrimann 2017-03-05 14:42:49 +01:00
parent 2ff5114186
commit 695ff278b6
3 changed files with 3 additions and 14 deletions

View file

@ -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),
)
})

View file

@ -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)
}

View file

@ -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,