diff --git a/adapters/adapter.go b/adapters/adapter.go deleted file mode 100644 index f87d454..0000000 --- a/adapters/adapter.go +++ /dev/null @@ -1,15 +0,0 @@ -package adapters - -import "net/http" - -// Adapter is an HTTP middleware -type Adapter func(http.Handler) http.Handler - -// Adapt applies adapters to an HTTP handler function -func Adapt(h http.Handler, adapters ...Adapter) http.Handler { - for i := len(adapters) - 1; i >= 0; i-- { - h = adapters[i](h) - } - - return h -} diff --git a/adapters/logging.go b/adapters/logging.go deleted file mode 100644 index 1e6d2a3..0000000 --- a/adapters/logging.go +++ /dev/null @@ -1,25 +0,0 @@ -package adapters - -import ( - "log" - "net/http" - "time" -) - -// Logging logs HTTP requests -func Logging(logger *log.Logger) Adapter { - return func(next http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - defer func(start time.Time) { - logger.Printf( - "%s\t%s\t%s", - r.Method, - r.RequestURI, - time.Since(start), - ) - }(time.Now()) - - next.ServeHTTP(w, r) - }) - } -} diff --git a/glide.lock b/glide.lock index d16637d..a93554f 100644 --- a/glide.lock +++ b/glide.lock @@ -1,10 +1,14 @@ -hash: 5af937afdf2e2b202f0394765f6fa07af14098dd77047df4705611751b70fc16 -updated: 2017-04-02T17:09:45.925326395+02:00 +hash: 9b88c8ce183463a407bdb87f79b6b857d8343a7bb5ce4723223c539c654d6d6d +updated: 2017-04-03T14:10:47.88086765+02:00 imports: - name: github.com/gorilla/context - version: 08b5f424b9271eedf6f9f0ce86cb9396ed337a42 + version: 1ea25387ff6f684839d82767c1733ff4d4d15d0a - name: github.com/gorilla/mux version: 392c28fe23e1c45ddba891b0320b3b5df220beea +- name: github.com/mastertinner/adapters + version: 4066d5a6918fa50f51471aea41771c61deca0680 + subpackages: + - logging - name: github.com/minio/minio-go version: dcaae9ec4d0b0a81d17f22f6d7a186491f6a55ec subpackages: diff --git a/glide.yaml b/glide.yaml index fabbf51..72842e2 100644 --- a/glide.yaml +++ b/glide.yaml @@ -8,3 +8,6 @@ import: version: ^1.1.4 subpackages: - assert +- package: github.com/mastertinner/adapters + subpackages: + - logging