Describe the bug
chizap can't properly get the request id value from the context due to working with another major version of go-chi
To Reproduce
Steps to reproduce the behavior:
- Install
go-chi with major version suffix like /v5 (github.com/go-chi/chi/v5)
- Build and run small example below
package main
import (
"fmt"
"net/http"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"go.uber.org/zap"
"moul.io/chizap"
)
func main() {
logger, _ := zap.NewProduction()
r := chi.NewRouter()
r.Use(middleware.RequestID)
r.Use(chizap.New(logger, &chizap.Opts{
WithReferer: true,
WithUserAgent: true,
}))
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Request ID: %s", middleware.GetReqID(r.Context()))
})
http.ListenAndServe(":3000", r)
}
Expected behavior
The request id should be presented in logs
Versions (please complete the following information, if relevant):
- Software version: the latest
- OS: macOS
- Golang version 1.19.5
Additional context
I'm new in Go and idk how to contribute to your project, but I maybe know why it doesn't work. Each version of go-chi creates its own type (link to src). My project works on chi/v5 and writes the value to the context by own RequestIDKey. When chizap tries to read the value from the same context it attempts to read the value by RequestIDKey from chi version v1.5.4 (according to your go.mod). It doesn't exist and logs contain the empty request id.
Describe the bug
chizapcan't properly get the request id value from the context due to working with another major version ofgo-chiTo Reproduce
Steps to reproduce the behavior:
go-chiwith major version suffix like /v5 (github.com/go-chi/chi/v5)Expected behavior
The request id should be presented in logs
Versions (please complete the following information, if relevant):
Additional context
I'm new in Go and idk how to contribute to your project, but I maybe know why it doesn't work. Each version of
go-chicreates its own type (link to src). My project works onchi/v5and writes the value to the context by ownRequestIDKey. Whenchizaptries to read the value from the same context it attempts to read the value byRequestIDKeyfrom chi version v1.5.4 (according to your go.mod). It doesn't exist and logs contain the empty request id.