A FAIRE.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

59 lines
1.7 KiB

/*
------------------------------------------------------------------------------------------------------------------------
####### middleware ####### Copyright (c) 2021 mls-361 ############################################## MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package middleware
import (
"forge.chapril.org/mls-361/jsonapi"
"forge.chapril.org/armen/armen/internal/components"
)
// Debug AFAIRE.
func Debug(next jsonapi.Handler, logger components.Logger) jsonapi.Handler {
return jsonapi.HandlerFunc(func(r *jsonapi.Request) {
logger.Debug( //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
"Request",
"id", r.ID(),
"from", r.RemoteAddr,
"method", r.Method,
"uri", r.URL.RequestURI(),
)
next.Serve(r)
logger.Debug( //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
"Response",
"id", r.ID(),
"status", r.Status(),
)
})
}
// Trace AFAIRE.
func Trace(next jsonapi.Handler, logger components.Logger) jsonapi.Handler {
return jsonapi.HandlerFunc(func(r *jsonapi.Request) {
logger.Trace( //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
"Request",
"id", r.ID(),
"from", r.RemoteAddr,
"method", r.Method,
"uri", r.URL.RequestURI(),
)
next.Serve(r)
logger.Trace( //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
"Response",
"id", r.ID(),
"status", r.Status(),
)
})
}
/*
######################################################################################################## @(°_°)@ #######
*/