Use github.com/gorilla/handlers for logging

This commit is contained in:
Lena Fuhrimann 2018-01-02 14:37:37 +01:00
parent 0a0b2b440b
commit 88c5ee3765
3 changed files with 21 additions and 28 deletions

26
Gopkg.lock generated
View file

@ -25,23 +25,23 @@
revision = "1ea25387ff6f684839d82767c1733ff4d4d15d0a" revision = "1ea25387ff6f684839d82767c1733ff4d4d15d0a"
version = "v1.1" version = "v1.1"
[[projects]]
name = "github.com/gorilla/handlers"
packages = ["."]
revision = "90663712d74cb411cbef281bc1e08c19d1a76145"
version = "v1.3.0"
[[projects]] [[projects]]
name = "github.com/gorilla/mux" name = "github.com/gorilla/mux"
packages = ["."] packages = ["."]
revision = "7f08801859139f86dfafd1c296e2cba9a80d292e" revision = "7f08801859139f86dfafd1c296e2cba9a80d292e"
version = "v1.6.0" version = "v1.6.0"
[[projects]]
branch = "master"
name = "github.com/mastertinner/adapters"
packages = [".","logging"]
revision = "f52f8e896fb9b6d7977f2feb502e18f0a061ba81"
[[projects]] [[projects]]
name = "github.com/minio/minio-go" name = "github.com/minio/minio-go"
packages = [".","pkg/credentials","pkg/encrypt","pkg/policy","pkg/s3signer","pkg/s3utils","pkg/set"] packages = [".","pkg/credentials","pkg/encrypt","pkg/policy","pkg/s3signer","pkg/s3utils","pkg/set"]
revision = "06dcf064d9e3b1dfd21b9a01a822da7665a9c971" revision = "e163d8055f79cf2a9b8af9d358b2814f21fd0472"
version = "4.0.4" version = "4.0.5"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -70,24 +70,24 @@
[[projects]] [[projects]]
name = "github.com/stretchr/testify" name = "github.com/stretchr/testify"
packages = ["assert"] packages = ["assert"]
revision = "69483b4bd14f5845b5a1e55bca19e954e827f1d0" revision = "b91bfb9ebec76498946beb6af7c0230c7cc7ba6c"
version = "v1.1.4" version = "v1.2.0"
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "golang.org/x/crypto" name = "golang.org/x/crypto"
packages = ["ssh/terminal"] packages = ["ssh/terminal"]
revision = "d585fd2cc9195196078f516b69daff6744ef5e84" revision = "0fcca4842a8d74bfddc2c96a073bd2a4d2a7a2e8"
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "golang.org/x/sys" name = "golang.org/x/sys"
packages = ["unix","windows"] packages = ["unix","windows"]
revision = "d818ba11af4465e00c1998bd3f8a55603b422290" revision = "83801418e1b59fb1880e363299581ee543af32ca"
[solve-meta] [solve-meta]
analyzer-name = "dep" analyzer-name = "dep"
analyzer-version = 1 analyzer-version = 1
inputs-digest = "5ab967c9abb8839deef83bb16468854f4bc3cf22123dbae72157241ccb6eb49a" inputs-digest = "d05a3975fc1101d4255ad3e3388ceaeeff30f95bcc7dcf00f8e3a37fd1cbfb0d"
solver-name = "gps-cdcl" solver-name = "gps-cdcl"
solver-version = 1 solver-version = 1

View file

@ -21,17 +21,17 @@
# version = "2.4.0" # version = "2.4.0"
[[constraint]]
name = "github.com/gorilla/handlers"
version = "1.3.0"
[[constraint]] [[constraint]]
name = "github.com/gorilla/mux" name = "github.com/gorilla/mux"
version = "1.6.0" version = "1.6.0"
[[constraint]]
branch = "master"
name = "github.com/mastertinner/adapters"
[[constraint]] [[constraint]]
name = "github.com/minio/minio-go" name = "github.com/minio/minio-go"
version = "4.0.4" version = "4.0.5"
[[constraint]] [[constraint]]
name = "github.com/pkg/errors" name = "github.com/pkg/errors"
@ -39,4 +39,4 @@
[[constraint]] [[constraint]]
name = "github.com/stretchr/testify" name = "github.com/stretchr/testify"
version = "1.1.4" version = "1.2.0"

View file

@ -6,9 +6,8 @@ import (
"net/http" "net/http"
"os" "os"
"github.com/gorilla/handlers"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/mastertinner/adapters"
"github.com/mastertinner/adapters/logging"
"github.com/mastertinner/s3manager" "github.com/mastertinner/s3manager"
minio "github.com/minio/minio-go" minio "github.com/minio/minio-go"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -41,9 +40,6 @@ func main() {
log.Fatalln(errors.Wrap(err, "error creating s3 client")) log.Fatalln(errors.Wrap(err, "error creating s3 client"))
} }
// Set up logger
l := log.New(os.Stdout, "", log.Ldate|log.Ltime)
// Set up router // Set up router
r := mux.NewRouter().StrictSlash(true) r := mux.NewRouter().StrictSlash(true)
r. r.
@ -85,8 +81,5 @@ func main() {
Path("/api/buckets/{bucketName}/objects/{objectName}"). Path("/api/buckets/{bucketName}/objects/{objectName}").
Handler(s3manager.DeleteObjectHandler(s3)) Handler(s3manager.DeleteObjectHandler(s3))
log.Fatal(http.ListenAndServe(":"+*port, adapters.Adapt( log.Fatal(http.ListenAndServe(":"+*port, handlers.LoggingHandler(os.Stdout, r)))
r,
logging.Handler(l),
)))
} }