mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-11 22:20:18 +00:00
Move RecoverPanics to be the top level wrapped handler. Add new method to be sure a logger has been generated instead of assuming one has. Move regexp list compilation into a utility and pass regexp list into CORS.
This commit is contained in:
@@ -95,6 +95,15 @@ func LogOf(w http.ResponseWriter) *respLogger {
|
||||
panic("Logger not installed yet!")
|
||||
}
|
||||
|
||||
// Returns the existing logger hiding in w. If there is not an existing logger
|
||||
// then one will be created.
|
||||
func FindOrCreateLogOf(req *http.Request, w *http.ResponseWriter) *respLogger {
|
||||
if _, exists := (*w).(*respLogger); !exists {
|
||||
NewLogged(req, w)
|
||||
}
|
||||
return LogOf(*w)
|
||||
}
|
||||
|
||||
// Unlogged returns the original ResponseWriter, or w if it is not our inserted logger.
|
||||
func Unlogged(w http.ResponseWriter) http.ResponseWriter {
|
||||
if rl, ok := w.(*respLogger); ok {
|
||||
|
Reference in New Issue
Block a user