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

View file

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

View file

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