Go to file
Marvin Steadfast 0123e90f9c
All checks were successful
continuous-integration/drone/push Build is passing
Bump version: 0.0.0 → 0.0.1
2020-10-13 15:26:44 +02:00
.github/workflows first commit 2020-10-13 15:26:40 +02:00
vendor first commit 2020-10-13 15:26:40 +02:00
.bumpversion.cfg Bump version: 0.0.0 → 0.0.1 2020-10-13 15:26:44 +02:00
.drone.yml first commit 2020-10-13 15:26:40 +02:00
.gitignore first commit 2020-10-13 15:26:40 +02:00
.goreleaser.yml first commit 2020-10-13 15:26:40 +02:00
go.mod first commit 2020-10-13 15:26:40 +02:00
go.sum first commit 2020-10-13 15:26:40 +02:00
logginghandler_test.go first commit 2020-10-13 15:26:40 +02:00
logginghandler.go first commit 2020-10-13 15:26:40 +02:00
Makefile first commit 2020-10-13 15:26:40 +02:00
README.md first commit 2020-10-13 15:26:40 +02:00

logginghandler

Build Status

Just a simple zerolog based request logging http middleware. It also sets a X-Request-ID in the request and response headers.

Install

    go get -v git.xsfx.dev/xsteadfastx/logginghandler

Usage

    handler := logginghandler.Handler(http.HandlerFunc(myHandler))
    http.HandleFunc("/", handler)
    log.Fatal().Msg(http.ListenAndServe(":5000", nil).Error())

In other handlers you can access the UUID:

    func anotherHandler(w http.ResponseWriter, r *http.Request) {
            fmt.Fprintf(w, "your uuid is: %s", logginghandler.GetUUID(r))
    }

The already prepared logger is also available:

    l := loggerhandler.Logger(r)
    l.Info().Msg("foo bar")