mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-19 11:36:57 +00:00
add reqId to all logging messages I could find
This commit is contained in:
parent
2438de0eb2
commit
f87c692f7a
17 changed files with 89 additions and 54 deletions
|
@ -5,19 +5,30 @@ import (
|
|||
"net/http"
|
||||
|
||||
"codeberg.org/codeberg/pages/server/utils"
|
||||
"github.com/hashicorp/go-uuid"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
type Context struct {
|
||||
RespWriter http.ResponseWriter
|
||||
Req *http.Request
|
||||
StatusCode int
|
||||
ReqId string
|
||||
}
|
||||
|
||||
func New(w http.ResponseWriter, r *http.Request) *Context {
|
||||
req_uuid, err := uuid.GenerateUUID()
|
||||
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Failed to generate request id, assigning error value")
|
||||
req_uuid = "ERROR"
|
||||
}
|
||||
|
||||
return &Context{
|
||||
RespWriter: w,
|
||||
Req: r,
|
||||
StatusCode: http.StatusOK,
|
||||
ReqId: req_uuid,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue