|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
/*
|
|
|
|
|
Copyright 2020-2023 CAcert Inc.
|
|
|
|
|
Copyright CAcert Inc.
|
|
|
|
|
SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
@ -63,6 +63,7 @@ func Logging(logger *log.Logger) func(http.Handler) http.Handler {
|
|
|
|
|
if !ok {
|
|
|
|
|
requestID = "unknown"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logger.Infof(
|
|
|
|
|
"[%s] %s \"%s %s\" %d %d \"%s\"",
|
|
|
|
|
requestID,
|
|
|
|
@ -86,7 +87,9 @@ func Tracing(nextRequestID func() string) func(http.Handler) http.Handler {
|
|
|
|
|
if requestID == "" {
|
|
|
|
|
requestID = nextRequestID()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ctx := context.WithValue(r.Context(), requestIDKey, requestID)
|
|
|
|
|
|
|
|
|
|
w.Header().Set("X-Request-Id", requestID)
|
|
|
|
|
next.ServeHTTP(w, r.WithContext(ctx))
|
|
|
|
|
})
|
|
|
|
@ -96,7 +99,7 @@ func Tracing(nextRequestID func() string) func(http.Handler) http.Handler {
|
|
|
|
|
var Healthy int32
|
|
|
|
|
|
|
|
|
|
func NewHealthHandler() http.Handler {
|
|
|
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
return http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
|
|
|
|
if atomic.LoadInt32(&Healthy) == 1 {
|
|
|
|
|
w.WriteHeader(http.StatusNoContent)
|
|
|
|
|
|
|
|
|
|